Class HiddenField
- java.lang.Object
-
- org.openidentityplatform.openam.click.control.AbstractControl
-
- org.openidentityplatform.openam.click.control.Field
-
- org.openidentityplatform.openam.click.control.HiddenField
-
- All Implemented Interfaces:
Serializable,org.apache.click.Stateful,org.openidentityplatform.openam.click.Control
public class HiddenField extends Field
Provides a Hidden Field control: <input type='hidden'>.The HiddenField control is useful for storing state information in a Form, such as object ids, instead of using the Session object. This control is capable of supporting the following classes:
- Boolean
- Date
- Double
- Float
- Integer
- Long
- Short
- String
- Serializable
Serializable non-primitive objects will be serialized, compressed and Base64 encoded, using
ClickUtils.encode(Object)method, and decoded using the correspondingClickUtils.decode(String)method.HiddenField Example
An example is provided below which uses a hidden field to count the number of times a form is consecutively submitted. The count is displayed in the page template using the model "count" value.public class CountPage extends Page { public Form form = new Form(); public Integer count; private HiddenField counterField = new HiddenField("counterField", Integer.class); public CountPage() { form.add(counterField); form.add(new Submit("ok", " OK ")); } public void onGet() { count = new Integer(0); counterField.setValueObject(count); } public void onPost() { count = (Integer) counterField.getValueObject(); count = new Integer(count.intValue() + 1); counterField.setValueObject(count); } }
See also W3C HTML reference INPUT- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<?>valueClassThe field value Class.protected ObjectvalueObjectThe field value Object.-
Fields inherited from class org.openidentityplatform.openam.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.openidentityplatform.openam.click.control.AbstractControl
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles
-
-
Constructor Summary
Constructors Constructor Description HiddenField()Create an HiddenField with no name or Class defined.HiddenField(String name, Class<?> valueClass)Construct a HiddenField with the given name and Class.HiddenField(String name, Object value)Construct a HiddenField with the given name and value object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbindRequestValue()This method binds the submitted request value to the Field's value.StringgetTag()Return the hiddenfield's html tag:input.StringgetType()Return the input type: 'hidden'.StringgetValidationJavaScript()Returns null to ensure no client side JavaScript validation is performed.StringgetValue()Return the Field value.Class<?>getValueClass()Return the registered Class for the Hidden Field value Object.ObjectgetValueObject()Return the value Object of the hidden field.booleanisHidden()Returns true.voidrender(HtmlStringBuffer buffer)Render the HTML representation of the HiddenField.voidsetValue(String value)Set the Field value.voidsetValueClass(Class<?> valueClass)Set the registered Class for the Hidden Field value Object.voidsetValueObject(Object value)Set the value of the field using the given object.-
Methods inherited from class org.openidentityplatform.openam.click.control.Field
getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getId, getLabel, getLabelStyle, getLabelStyleClass, getParentStyleClassHint, getParentStyleHint, getRequestValue, getState, getTabIndex, getTextAlign, getTitle, getValidate, getWidth, isDisabled, isReadonly, isRequired, isTrim, isValid, onProcess, 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, setWidth, validate
-
Methods inherited from class org.openidentityplatform.openam.click.control.AbstractControl
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getControlSizeEst, 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
-
-
-
-
Constructor Detail
-
HiddenField
public HiddenField(String name, Class<?> valueClass)
Construct a HiddenField with the given name and Class.- Parameters:
name- the name of the hidden fieldvalueClass- the Class of the value Object
-
HiddenField
public HiddenField(String name, Object value)
Construct a HiddenField with the given name and value object.- Parameters:
name- the name of the hidden fieldvalue- the value object
-
HiddenField
public HiddenField()
Create an HiddenField with no name or Class defined. Please note the HiddenField's name and value Class must be defined before it is valid.
-
-
Method Detail
-
getTag
public String getTag()
Return the hiddenfield's html tag:input.- Overrides:
getTagin classAbstractControl- Returns:
- this controls html tag
- See Also:
AbstractControl.getTag()
-
isHidden
public boolean isHidden()
Returns true.
-
getType
public String getType()
Return the input type: 'hidden'.- Returns:
- the input type: 'hidden'
-
setValue
public void setValue(String value)
Description copied from class:FieldSet the Field value.
-
getValueClass
public Class<?> getValueClass()
Return the registered Class for the Hidden Field value Object.- Returns:
- the registered Class for the Hidden Field value Object
-
setValueClass
public void setValueClass(Class<?> valueClass)
Set the registered Class for the Hidden Field value Object.- Parameters:
valueClass- the registered Class for the Hidden Field value Object
-
getValueObject
public Object getValueObject()
Return the value Object of the hidden field.- Overrides:
getValueObjectin classField- Returns:
- the object representation of the Field value
- See Also:
Field.getValueObject()
-
setValueObject
public void setValueObject(Object value)
Description copied from class:FieldSet the value of the field using the given object.- Overrides:
setValueObjectin classField- Parameters:
value- the object value to set- See Also:
Field.setValueObject(Object)
-
getValidationJavaScript
public String getValidationJavaScript()
Returns null to ensure no client side JavaScript validation is performed.- Overrides:
getValidationJavaScriptin classField- Returns:
- null to ensure no client side JavaScript validation is performed
-
bindRequestValue
public void bindRequestValue()
This method binds the submitted request value to the Field's value.- Overrides:
bindRequestValuein classField
-
render
public void render(HtmlStringBuffer buffer)
Render the HTML representation of the HiddenField.- Specified by:
renderin interfaceorg.openidentityplatform.openam.click.Control- Overrides:
renderin classAbstractControl- Parameters:
buffer- the specified buffer to render the control's output to- See Also:
Control.render(HtmlStringBuffer)
-
-