net.sf.click.control
Class ImageSubmit

java.lang.Object
  extended bynet.sf.click.control.AbstractControl
      extended bynet.sf.click.control.Field
          extended bynet.sf.click.control.Button
              extended bynet.sf.click.control.Submit
                  extended bynet.sf.click.control.ImageSubmit
All Implemented Interfaces:
Control, Serializable

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

Author:
Phil Barnes, Malcolm Edgar
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 net.sf.click.control.Submit
clicked
 
Fields inherited from class net.sf.click.control.Field
disabled, error, focus, form, help, label, readonly, required, tabindex, title, validate, value
 
Fields inherited from class net.sf.click.control.AbstractControl
actionListener, attributes, listener, listenerMethod, messages, name, parent, styles
 
Fields inherited from interface net.sf.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.
 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 net.sf.click.control.Submit
getCancelJavaScriptValidation, isClicked, onProcess, setCancelJavaScriptValidation
 
Methods inherited from class net.sf.click.control.Button
getControlSizeEst, getOnClick, getTag, onRender, setOnClick
 
Methods inherited from class net.sf.click.control.Field
getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getId, getLabel, getRequestValue, getTabIndex, getTextAlign, getTitle, getValidate, getValidationJavaScript, getValue, getValueObject, getWidth, isDisabled, isHidden, isReadonly, isRequired, isValid, onInit, setDisabled, setError, setErrorMessage, setErrorMessage, setErrorMessage, setErrorMessage, setFocus, setForm, setHelp, setLabel, setListener, setParent, setReadonly, setRequired, setTabIndex, setTextAlign, setTitle, setValidate, setValue, setValueObject, setWidth, validate
 
Methods inherited from class net.sf.click.control.AbstractControl
addStyleClass, appendAttributes, getActionListener, getAttribute, getAttributes, getContext, getHtmlImports, getMessage, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasStyles, onDeploy, onDestroy, registerActionEvent, removeStyleClass, renderTagBegin, 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

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()