org.apache.click.extras.control
Class HiddenList

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

public class HiddenList
extends Field

Provides a control for rendering a list of Hidden Fields:   <input type='hidden'>.

Click also provides the HiddenField to render <input type="hidden">, however HiddenField can not render multiple values under the same name.

HiddenList supports multiple values under the same name by rendering the values as multiple hidden fields.

HiddenList Examples

 HiddenList hiddenList = new HiddenList("customerId");
 hiddenList.addValue("123");
 hiddenList.addValue("678"); 
This HiddenList would generate following HTML:
 <input type="hidden" name="customerId" id="form-customerId_1" value="123"/>
 <input type="hidden" name="customerId" id="form-customerId_2" value="678"/> 

Since:
2.1.0
See Also:
Serialized Form

Field Summary
protected  List<String> valueObject
          The hidden values.
 
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
HiddenList()
          Create a default HiddenList.
HiddenList(String name)
          Create a HiddenList with the given name.
 
Method Summary
 void addValue(String value)
          Add the given value to this HiddenList.
 void bindRequestValue()
          This method binds the submitted request values to the HiddenList values.
 Object getValueObject()
          Returns the list of added values as a java.util.List of Strings.
 List<String> getValues()
          This method delegates to getValueObject() to return the hidden values as a java.util.List of Strings.
 boolean isHidden()
          Returns true.
 void render(HtmlStringBuffer buffer)
          Render the HTML representation of the HiddenField.
 void setValueObject(Object valueObject)
          Set the list of hidden values.
 
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, 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, setValue, setWidth, validate
 
Methods inherited from class org.apache.click.control.AbstractControl
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getControlSizeEst, getHeadElements, getHtmlImports, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, getTag, 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

valueObject

protected List<String> valueObject
The hidden values.

Constructor Detail

HiddenList

public HiddenList(String name)
Create a HiddenList with the given name.

Parameters:
name - the name of the field

HiddenList

public HiddenList()
Create a default HiddenList.

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

Method Detail

setValueObject

public void setValueObject(Object valueObject)
Set the list of hidden values.

Overrides:
setValueObject in class Field
Parameters:
valueObject - a list of Strings

getValueObject

public Object getValueObject()
Returns the list of added values as a java.util.List of Strings.

Overrides:
getValueObject in class Field
Returns:
a list of Strings

getValues

public List<String> getValues()
This method delegates to getValueObject() to return the hidden values as a java.util.List of Strings.

Returns:
a list of Strings

addValue

public void addValue(String value)
Add the given value to this HiddenList.

Parameters:
value - the hidden value to add

bindRequestValue

public void bindRequestValue()
This method binds the submitted request values to the HiddenList values.

Please note: while it is possible to explicitly bind the field value by invoking this method directly, it is recommended to use the "bind" utility methods in ClickUtils instead. See ClickUtils.bind(org.apache.click.control.Field) for more details.

Overrides:
bindRequestValue in class Field

isHidden

public boolean isHidden()
Returns true.

Overrides:
isHidden in class Field
Returns:
true
See Also:
Field.isHidden()

render

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

Specified by:
render in interface Control
Overrides:
render in class AbstractControl
Parameters:
buffer - the specified buffer to render the control's output to
See Also:
Control.render(org.apache.click.util.HtmlStringBuffer)