Class 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.
  • Constructor Details

    • 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 Details

    • 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(fc.web.forms.FormData) 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

      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(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(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(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 invalid input: '{@link Boolean.valueOf(String)'} method. If more than one value exists, use the getValues(FormData) method instead.
    • setValueFromSubmit

      public void setValueFromSubmit(FormData fd, jakarta.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