fc.web.forms
Class Hidden

java.lang.Object
  extended by fc.web.forms.Field
      extended by fc.web.forms.Hidden

public final class Hidden
extends Field

Represents an HTML hidden field. If this object is created with an array of string values, then each string value will be written out as a seperate hidden field and all such written hidden fields will have the same name. When the form is submitted, all values can be retrieved as an array of strings.


Nested Class Summary
 
Nested classes/interfaces inherited from class fc.web.forms.Field
Field.Type
 
Constructor Summary
Hidden(String name)
          Creates a new text element with the initial value set to an empty string.
Hidden(String name, int value)
          Convenience constructor to creates a new hidden element with the specified initial integer value (converted to a string).
Hidden(String name, List values)
          Creates a new hidden element with the specified initial values.
Hidden(String name, String value)
          Creates a new hidden element with the specified initial value.
Hidden(String name, String[] values)
          Creates a new hidden element with the specified initial values.
 
Method Summary
 boolean getBooleanValue(FormData fd)
          Convenience method that returns one value of this field as a boolean.
 int getIntValue(FormData fd)
          Convenience method that returns one value of this field as a Integer.
 short getShortValue(FormData fd)
          Convenience method that returns one value of this field as a Short.
 String getStringValue(FormData fd)
          Convenience method that returns one value of this field as a String with null values being returned as an empty string).
 Field.Type getType()
          Subclasses should return an appropriate Field.Type.
 String getValue(FormData fd)
          Returns a String representing the value of this field or null if there is no current value.
 String[] getValues(FormData fd)
          Returns a String[] containing all values associated with this field.
 boolean isFilled(FormData fd)
          Returns true if this field was isFilled out or selected by the user, false otherwise.
 void renderImpl(FormData fd, Writer writer)
           
 void reset(FormData fd)
           
 void setValue(String value)
          Sets the initial values of this text element.
 void setValue(String[] values)
          Sets the initial values of this text element.
 void setValueFromSubmit(FormData fd, javax.servlet.http.HttpServletRequest req)
          This method sets the value of this field from the parameters obtained from the specified request.
 String toString()
           
 
Methods inherited from class fc.web.forms.Field
add, addError, addLabel, addString, disable, disable, enable, enable, getLabel, getName, getValidateErrors, isEnabled, render, render, render, renderError, renderError, renderStyleTag, setStyleTag, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Hidden

public Hidden(String name)
Creates a new text element with the initial value set to an empty string. This is useful in cases where we are interested in the presense/absense of the name of the hidden field and don't care about a seperate value.


Hidden

public Hidden(String name,
              String value)
Creates a new hidden element with the specified initial value. If the initial value is specified as null, it is set to be an empty string.


Hidden

public Hidden(String name,
              int value)
Convenience constructor to creates a new hidden element with the specified initial integer value (converted to a string).


Hidden

public Hidden(String name,
              String[] values)
Creates a new hidden element with the specified initial values.


Hidden

public Hidden(String name,
              List values)
Creates a new hidden element with the specified initial values. Each element in the List will be added by invoking toString on it.

Method Detail

getType

public Field.Type getType()
Description copied from class: Field
Subclasses should return an appropriate Field.Type. This type is rendered as part of <input type= ...

Specified by:
getType in class Field

renderImpl

public void renderImpl(FormData fd,
                       Writer writer)
                throws IOException
Specified by:
renderImpl in class Field
Throws:
IOException

getValue

public String getValue(FormData fd)
Returns a String representing the value of this field or null if there is no current value. If more than one value exists for this hidden field, use the getValues method. If called when more than one value exists, this method will return any 1 arbitrary value.


getValues

public String[] getValues(FormData fd)
Returns a String[] containing all values associated with this field.


getStringValue

public String getStringValue(FormData fd)
Convenience method that returns one value of this field as a String with null values being returned as an empty string). If more than one value exists, use the getValues(fc.web.forms.FormData) method instead.

Throws:
NumberFormatException - if the value could not be returned as in integer.

getIntValue

public int getIntValue(FormData fd)
Convenience method that returns one value of this field as a Integer. If more than one value exists, use the getValues(fc.web.forms.FormData) method instead.

Throws:
NumberFormatException - if the value could not be returned as an integer.

getShortValue

public short getShortValue(FormData fd)
Convenience method that returns one value of this field as a Short. If more than one value exists, use the getValues(fc.web.forms.FormData) method instead.

Throws:
NumberFormatException - if the value could not be returned as a short.

getBooleanValue

public boolean getBooleanValue(FormData fd)
Convenience method that returns one value of this field as a boolean. The value is converted into a boolean as per the Boolean.valueOf(String) method. If more than one value exists, use the getValues(fc.web.forms.FormData) method instead.


setValueFromSubmit

public void setValueFromSubmit(FormData fd,
                               javax.servlet.http.HttpServletRequest req)
                        throws SubmitHackedException
Description copied from class: Field
This method sets the value of this field from the parameters obtained from the specified request. The name of the parameter to obtain this value will typically be the name of this field itself.

Specified by:
setValueFromSubmit in class Field
Parameters:
fd - the form data object to store the value in
Throws:
SubmitHackedException

setValue

public void setValue(String[] values)
Sets the initial values of this text element.


setValue

public void setValue(String value)
Sets the initial values of this text element.


isFilled

public boolean isFilled(FormData fd)
Description copied from class: Field
Returns true if this field was isFilled out or selected by the user, false otherwise.

Note: Some fields like selects will never be empty since non-multiple select fields always send their default selected value. [although select/with/multiple can be empty since the browser sends (much like radio buttoms) nothing at all when no option is selected].

Specified by:
isFilled in class Field

reset

public void reset(FormData fd)

toString

public String toString()
Overrides:
toString in class Field