|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.click.control.AbstractControl org.apache.click.control.Field org.apache.click.control.Button org.apache.click.control.ActionButton
public class ActionButton
Provides a ActionButton control: <input type="button"/>.
ActionLink
control, where you can attach
action listeners to the button. When the button is clicked it will make a
JavaScript GET request. This request is then processed by the ActionButton
and its listener is invoked.
ActionButton actionButton = new ActionButton("button"); actionButton.setListener(this, "onButtonClick"); addControl(actionButton);Please Note do not add ActionButton instances to the Form object, as the GET request it generates will never be processed by the Form, and in turn the Form will not invoke the ActionButton's onProcess() method.
ActionLink
,
Serialized FormField Summary | |
---|---|
static String |
ACTION_BUTTON
The action button parameter name: actionButton. |
protected boolean |
clicked
The button is clicked. |
protected Map<String,Object> |
parameters
The button parameters map. |
static String |
VALUE
The value parameter name: value. |
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 | |
---|---|
ActionButton()
Create an ActionButton with no name defined. |
|
ActionButton(Object listener,
String method)
Create an ActionButton for the given listener object and listener method. |
|
ActionButton(String name)
Create an ActionButton for the given name. |
|
ActionButton(String name,
Object listener,
String method)
Create an ActionButton for the given name, listener object and listener method. |
|
ActionButton(String name,
String label)
Create an ActionButton for the given name and label. |
|
ActionButton(String name,
String label,
Object listener,
String method)
Create an ActionButton for the given name, label, listener object and listener method. |
Method Summary | |
---|---|
protected void |
bindRequestParameters(Context context)
This method binds the submitted request parameters to the buttons parameters. |
void |
bindRequestValue()
This method binds the submitted request value to the ActionButton's value. |
void |
defineParameter(String name)
Defines a button parameter that will have its value bound to a matching request parameter. |
String |
getOnClick()
Return the ActionButton anchor <a> tag href attribute value. |
String |
getOnClick(Object value)
Return the ActionButton onclick attribute for the given value. |
String |
getParameter(String name)
Return the button request parameter value for the given name, or null if the parameter value does not exist. |
Map<String,Object> |
getParameters()
Return the ActionButton parameters Map. |
String |
getValue()
Returns the ActionButton value if the action link was processed and has a value, or null otherwise. |
Double |
getValueDouble()
Returns the ActionButton Double value if the action button was processed and has a value, or null otherwise. |
Integer |
getValueInteger()
Returns the ActionButton Integer value if the action button was processed and has a value, or null otherwise. |
Long |
getValueLong()
Returns the ActionButton Long value if the action button was processed and has a value, or null otherwise. |
Object |
getValueObject()
Return the value of the ActionButton. |
boolean |
hasParameters()
Return true if the ActionButton has parameters or false otherwise. |
boolean |
isAjaxTarget(Context context)
Returns true if this control is an AJAX target, false otherwise. |
boolean |
isClicked()
Returns true if the ActionButton was clicked, otherwise returns false. |
boolean |
onProcess()
This method will set the isClicked() property to true if the
ActionButton was clicked, and if an action callback listener was set
this will be invoked. |
void |
render(HtmlStringBuffer buffer)
Render the HTML representation of the ActionButton. |
void |
setName(String name)
Set the name of the Control. |
void |
setParameter(String name,
String value)
Set the button parameter with the given parameter name and value. |
void |
setParameters(Map parameters)
Set the ActionButton parameter map. |
void |
setParent(Object parent)
Set the parent of the ActionButton. |
void |
setValue(String value)
Set the ActionButton value. |
void |
setValueObject(Object object)
Set the value of the field using the given object. |
Methods inherited from class org.apache.click.control.Button |
---|
getControlSizeEst, getTag, getType, 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, getWidth, isDisabled, isHidden, isReadonly, isRequired, isTrim, isValid, removeState, renderTagBegin, restoreState, saveState, setDisabled, setError, setErrorMessage, setErrorMessage, setFocus, setForm, setHelp, setLabel, setLabelStyle, setLabelStyleClass, setListener, setParentStyleClassHint, setParentStyleHint, setReadonly, setRequired, setState, setTabIndex, setTextAlign, setTitle, setTrim, setValidate, 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, onDeploy, onDestroy, onInit, onRender, removeBehavior, removeStyleClass, renderTagEnd, setActionListener, setAttribute, setId, setStyle, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String ACTION_BUTTON
public static final String VALUE
protected boolean clicked
protected Map<String,Object> parameters
Constructor Detail |
---|
public ActionButton(String name)
name
- the action button name
IllegalArgumentException
- if the name is nullpublic ActionButton(String name, String label)
name
- the action button namelabel
- the action button label
IllegalArgumentException
- if the name is nullpublic ActionButton(Object listener, String method)
listener
- the listener target objectmethod
- the listener method to call
IllegalArgumentException
- if the name, listener or method is null
or if the method is blankpublic ActionButton(String name, Object listener, String method)
name
- the action button namelistener
- the listener target objectmethod
- the listener method to call
IllegalArgumentException
- if the name, listener or method is null
or if the method is blankpublic ActionButton(String name, String label, Object listener, String method)
name
- the action button namelabel
- the action button labellistener
- the listener target objectmethod
- the listener method to call
IllegalArgumentException
- if the name, listener or method is null
or if the method is blankpublic ActionButton()
Method Detail |
---|
public boolean isClicked()
public void setName(String name)
setName
in interface Control
setName
in class AbstractControl
name
- of the control
IllegalArgumentException
- if the name is nullControl.setName(String)
public void setParent(Object parent)
setParent
in interface Control
setParent
in class Field
parent
- the parent of the Control
IllegalStateException
- if AbstractControl.name
is not defined
IllegalArgumentException
- if the given parent instance is
referencing this object: if (parent == this)Control.setParent(Object)
public String getOnClick(Object value)
value
- the ActionButton value parameter
public String getOnClick()
getOnClick
in class Button
public String getParameter(String name)
name
- the name of request parameter
public void setParameter(String name, String value)
name
- the attribute namevalue
- the attribute value
IllegalArgumentException
- if name parameter is nullpublic Map<String,Object> getParameters()
public void setParameters(Map parameters)
parameters
- the button parameter mappublic void defineParameter(String name)
setParameter
implicitly defines a parameter as well.
Please note: parameters need only be defined for Ajax requests.
For non-Ajax requests, all incoming request parameters
are bound, whether they are defined or not. This behavior may change in a
future release.
Also note: button parameters are bound to request parameters
during the onProcess()
event, so button parameters must be defined
in the Page constructor or onInit() event.
name
- the name of the parameter to definepublic boolean hasParameters()
public boolean isAjaxTarget(Context context)
AbstractControl
ID
is send as a request parameter.
isAjaxTarget
in interface Control
isAjaxTarget
in class AbstractControl
context
- the request context
public String getValue()
getValue
in class Field
public Double getValueDouble()
NumberFormatException
- if the value cannot be parsed into a Doublepublic Integer getValueInteger()
NumberFormatException
- if the value cannot be parsed into an Integerpublic Long getValueLong()
NumberFormatException
- if the value cannot be parsed into a Longpublic void setValue(String value)
setValue
in class Field
value
- the ActionButton valuepublic Object getValueObject()
getValueObject
in class Field
public void setValueObject(Object object)
setValueObject
in class Field
object
- the object value to setpublic void bindRequestValue()
bindRequestValue
in class Field
public boolean onProcess()
isClicked()
property to true if the
ActionButton was clicked, and if an action callback listener was set
this will be invoked.
onProcess
in interface Control
onProcess
in class Button
Field.onProcess()
public void render(HtmlStringBuffer buffer)
render
in interface Control
render
in class Button
buffer
- the specified buffer to render the control's output toAbstractControl.toString()
protected void bindRequestParameters(Context context)
context
- the request context
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |