org.apache.click.control
Class ImageSubmit

java.lang.Object
  extended by org.apache.click.control.AbstractControl
      extended by org.apache.click.control.Field
          extended by org.apache.click.control.Button
              extended by org.apache.click.control.Submit
                  extended by org.apache.click.control.ImageSubmit
All Implemented Interfaces:
Serializable, Control, Stateful

public class ImageSubmit
extends Submit

Provides an ImageSubmit control:   <input type='image' src='edit.gif'>.

The ImageSubmit control is useful for creating custom form buttons. This control can also be used for creating image areas where the user clicks on a point on the image and the clicked x and y coordinates are submitted with the name of the control.

See also W3C HTML reference INPUT

See Also:
Submit, Button, Serialized Form

Field Summary
protected  String src
          The image path src attribute.
protected  int x
          The image pixel x coordinate clicked on by the user, the default value is -1.
protected  int y
          The image pixel y coordinate clicked on by the user, the default value is -1.
 
Fields inherited from class org.apache.click.control.Submit
clicked
 
Fields inherited from class org.apache.click.control.Field
disabled, error, focus, form, help, label, labelStyle, labelStyleClass, parentStyleClassHint, parentStyleHint, readonly, required, tabindex, title, trim, validate, value
 
Fields inherited from class org.apache.click.control.AbstractControl
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles
 
Fields inherited from interface org.apache.click.Control
CONTROL_MESSAGES
 
Constructor Summary
ImageSubmit()
          Create an ImageSubmit button with no name defined.
ImageSubmit(String name)
          Create a ImageSubmit button with the given name.
ImageSubmit(String name, String src)
          Create a ImageSubmit button with the given name and image src path.
ImageSubmit(String name, String src, Object listener, String method)
          Create a ImageSubmit button with the given name, image src path, listener object and listener method.
 
Method Summary
 void bindRequestValue()
          Bind the request submission, setting the field Submit.clicked, x and y if defined in the request.
 String getSrc()
          Return the image src path attribute.
 String getType()
          Return the input type: 'image'.
 int getX()
          Return the image x pixel coordinate clicked on by the user.
 int getY()
          Return the image y pixel coordinate clicked on by the user.
 boolean onProcess()
          Process the submit event and return true to continue event processing.
 void render(HtmlStringBuffer buffer)
          Render the HTML representation of the ImageButton.
 void setSrc(String src)
          Set the image src path attribute.
 
Methods inherited from class org.apache.click.control.Submit
getCancelJavaScriptValidation, isClicked, setCancelJavaScriptValidation
 
Methods inherited from class org.apache.click.control.Button
getControlSizeEst, getOnClick, getTag, setOnClick
 
Methods inherited from class org.apache.click.control.Field
getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getId, getLabel, getLabelStyle, getLabelStyleClass, getParentStyleClassHint, getParentStyleHint, getRequestValue, getState, getTabIndex, getTextAlign, getTitle, getValidate, getValidationJavaScript, getValue, getValueObject, getWidth, isDisabled, isHidden, isReadonly, isRequired, isTrim, isValid, removeState, renderTagBegin, restoreState, saveState, setDisabled, setError, setErrorMessage, setErrorMessage, setFocus, setForm, setHelp, setLabel, setLabelStyle, setLabelStyleClass, setListener, setParent, setParentStyleClassHint, setParentStyleHint, setReadonly, setRequired, setState, setTabIndex, setTextAlign, setTitle, setTrim, setValidate, setValue, setValueObject, setWidth, validate
 
Methods inherited from class org.apache.click.control.AbstractControl
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHeadElements, getHtmlImports, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, onDestroy, onInit, onRender, removeBehavior, removeStyleClass, renderTagEnd, setActionListener, setAttribute, setId, setName, setStyle, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

src

protected String src
The image path src attribute. If the src value is prefixed with '/' then the request context path will be prefixed to the src value when rendered by the control.


x

protected int x
The image pixel x coordinate clicked on by the user, the default value is -1. A value of -1 which means the value has not been set.


y

protected int y
The image pixel y coordinate clicked on by the user, the default value is -1. A value of -1 means the value has not been set.

Constructor Detail

ImageSubmit

public ImageSubmit(String name)
Create a ImageSubmit button with the given name.

Parameters:
name - the button name

ImageSubmit

public ImageSubmit(String name,
                   String src)
Create a ImageSubmit button with the given name and image src path. If the src path value is prefixed with "/" the request context path will be prefixed to the src value when rendered in the control.

Parameters:
name - the button name
src - the image src path attribute

ImageSubmit

public ImageSubmit(String name,
                   String src,
                   Object listener,
                   String method)
Create a ImageSubmit button with the given name, image src path, listener object and listener method. If the src path value is prefixed with "/" the request context path will be prefixed to the src value when rendered in the control.

Parameters:
name - the button name
src - the image src path attribute
listener - the listener target object
method - the listener method to call

ImageSubmit

public ImageSubmit()
Create an ImageSubmit button with no name defined.

Please note the control's name must be defined before it is valid.

Method Detail

getType

public String getType()
Return the input type: 'image'.

Overrides:
getType in class Submit
Returns:
the input type: 'image'

getSrc

public String getSrc()
Return the image src path attribute. If the src value is prefixed with '/' then the request context path will be prefixed to the src value when rendered by the control.

Returns:
the image src path attribute

setSrc

public void setSrc(String src)
Set the image src path attribute. If the src value is prefixed with '/' then the request context path will be prefixed to the src value when rendered by the control.

Parameters:
src - the image src path attribute

getX

public int getX()
Return the image x pixel coordinate clicked on by the user. The x pixel value will be set after control has been processed. The default x value is -1 which means the value has not been set.

Returns:
the image x pixel coordinate clicked on by the user

getY

public int getY()
Return the image y pixel coordinate clicked on by the user. The y pixel value will be set after control has been processed. The default y value is -1 which means the value has not been set.

Returns:
the image y pixel coordinate clicked on by the user

bindRequestValue

public void bindRequestValue()
Bind the request submission, setting the field Submit.clicked, x and y if defined in the request.

Overrides:
bindRequestValue in class Submit

onProcess

public boolean onProcess()
Process the submit event and return true to continue event processing.

Specified by:
onProcess in interface Control
Overrides:
onProcess in class Submit
Returns:
true to continue Page event processing or false otherwise
See Also:
Submit.onProcess()

render

public void render(HtmlStringBuffer buffer)
Render the HTML representation of the ImageButton.

Specified by:
render in interface Control
Overrides:
render in class Button
Parameters:
buffer - the specified buffer to render the control's output to
See Also:
AbstractControl.toString()