au.id.jericho.lib.html
Class FormControlType

java.lang.Object
  extended byau.id.jericho.lib.html.FormControlType

public final class FormControlType
extends java.lang.Object

Represents one of the HTML control types in a form which have the potential to be successful. This means that they can contribute name/value pairs to the form data set when the form is submitted.

Each type of control has a certain behaviour in regards to the name/value pairs submitted. This class defines that behaviour, so that the meaning of the name/value pairs submitted from an arbitrary HTML page can be determined.

Use the StartTag.getFormControlType() method to determine the type of control (if any) represented by a start tag.

See Also:
FormField, FormFields

Field Summary
static FormControlType BUTTON
          <button type="submit" name="FieldName" value="PredefinedValue">Send</button>.
static FormControlType CHECKBOX
          <input type="checkbox" name="FieldName" value="PredefinedValue" />.
static FormControlType FILE
          <input type="file" name="FieldName" value="DefaultFileName" />.
static FormControlType HIDDEN
          <input type="hidden" name="FieldName" value="PredefinedValue" />.
static FormControlType IMAGE
          <input type="image" name="FieldName" src="ImageURL" value="PredefinedValue" />.
static FormControlType PASSWORD
          <input type="password" name="FieldName" value="DefaultValue" />.
static FormControlType RADIO
          <input type="radio" name="FieldName" value="PredefinedValue" />.
static FormControlType SELECT_MULTIPLE
          <select name="FieldName" multiple> <option value="PredefinedValue">Display Text</option> </select>.
static FormControlType SELECT_SINGLE
          <select name="FieldName"> <option value="PredefinedValue">Display Text</option> </select>.
static FormControlType SUBMIT
          <input type="submit" name="FieldName" value="PredefinedValue" />.
static FormControlType TEXT
          <input type="text" name="FieldName" value="DefaultValue" />.
static FormControlType TEXTAREA
          <textarea name="FieldName">Default Value</textarea>.
 
Method Summary
 boolean allowsMultipleValues()
          Deprecated. Use the more useful FormField.allowsMultipleValues() method instead.
static FormControlType get(java.lang.String formControlTypeId)
          Returns the FormControlType with the specified ID.
 java.lang.String[] getAdditionalSubmitNames(java.lang.String name)
          Deprecated. no replacement
 java.lang.String getFormControlTypeId()
          Returns a string which identifies this form control type.
 java.lang.String getTagName()
          Returns the name of the tag that defines this form control type.
static boolean isPotentialControl(java.lang.String tagName)
          Deprecated. no replacement
 boolean isPredefinedValue()
          Indicates whether any value submitted by this type of control is predefined in the HTML and typically not modified by the user or server/client scripts.
 boolean isSelect()
          Indicates whether this control type represents a select element.
 boolean isSubmit()
          Indicates whether this control type causes the form to be submitted.
 java.lang.String toString()
          Returns a string which identifies this form control type.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BUTTON

public static final FormControlType BUTTON
<button type="submit" name="FieldName" value="PredefinedValue">Send</button>.

getFormControlTypeId() = "button"
getTagName() = Tag.BUTTON
isPredefinedValue() = true
isSubmit() = true


CHECKBOX

public static final FormControlType CHECKBOX
<input type="checkbox" name="FieldName" value="PredefinedValue" />.

getFormControlTypeId() = "checkbox"
getTagName() = Tag.INPUT
isPredefinedValue() = true
isSubmit() = false


FILE

public static final FormControlType FILE
<input type="file" name="FieldName" value="DefaultFileName" />.

getFormControlTypeId() = "file"
getTagName() = Tag.INPUT
isPredefinedValue() = false
isSubmit() = false


HIDDEN

public static final FormControlType HIDDEN
<input type="hidden" name="FieldName" value="PredefinedValue" />.

getFormControlTypeId() = "hidden"
getTagName() = Tag.INPUT
isPredefinedValue() = false
isSubmit() = false

Note that isPredefinedValue() returns false for this control type because the value of hidden fields is usually set via server or client side scripting.


IMAGE

public static final FormControlType IMAGE
<input type="image" name="FieldName" src="ImageURL" value="PredefinedValue" />.

getFormControlTypeId() = "image"
getTagName() = Tag.INPUT
isPredefinedValue() = true
isSubmit() = true


PASSWORD

public static final FormControlType PASSWORD
<input type="password" name="FieldName" value="DefaultValue" />.

getFormControlTypeId() = "password"
getTagName() = Tag.INPUT
isPredefinedValue() = false
isSubmit() = false


RADIO

public static final FormControlType RADIO
<input type="radio" name="FieldName" value="PredefinedValue" />.

getFormControlTypeId() = "radio"
getTagName() = Tag.INPUT
isPredefinedValue() = true
isSubmit() = false


SELECT_MULTIPLE

public static final FormControlType SELECT_MULTIPLE
<select name="FieldName" multiple> <option value="PredefinedValue">Display Text</option> </select>.

getFormControlTypeId() = "select_multiple"
getTagName() = Tag.SELECT
isPredefinedValue() = true
isSubmit() = false


SELECT_SINGLE

public static final FormControlType SELECT_SINGLE
<select name="FieldName"> <option value="PredefinedValue">Display Text</option> </select>.

getFormControlTypeId() = "select_single"
getTagName() = Tag.SELECT
isPredefinedValue() = true
isSubmit() = false


SUBMIT

public static final FormControlType SUBMIT
<input type="submit" name="FieldName" value="PredefinedValue" />.

getFormControlTypeId() = "submit"
getTagName() = Tag.INPUT
isPredefinedValue() = true
isSubmit() = true


TEXT

public static final FormControlType TEXT
<input type="text" name="FieldName" value="DefaultValue" />.

getFormControlTypeId() = "text"
getTagName() = Tag.INPUT
isPredefinedValue() = false
isSubmit() = false


TEXTAREA

public static final FormControlType TEXTAREA
<textarea name="FieldName">Default Value</textarea>.

getFormControlTypeId() = "textarea"
getTagName() = Tag.TEXTAREA
isPredefinedValue() = false
isSubmit() = false

Method Detail

getFormControlTypeId

public java.lang.String getFormControlTypeId()
Returns a string which identifies this form control type.

This is the same as the control type's static field name in lower case, which is one of
button, checkbox, file, hidden, image, password, radio, select_multiple, select_single, submit, text, or textarea.

Returns:
a string which identifies this form control type.

getTagName

public java.lang.String getTagName()
Returns the name of the tag that defines this form control type.

Returns:
the name of the tag that defines this form control type.

isPredefinedValue

public boolean isPredefinedValue()
Indicates whether any value submitted by this type of control is predefined in the HTML and typically not modified by the user or server/client scripts.

The predefined value is defined by the control's initial value.

Note that the HIDDEN type returns false for this method because the value of hidden fields is usually set via server or client side scripting.

Returns:
true if any value submitted by this type of control is predefined in the HTML and typically not modified by the user or server/client scripts, otherwise false.

isSubmit

public boolean isSubmit()
Indicates whether this control type causes the form to be submitted.

Returns true only for the SUBMIT, BUTTON, and IMAGE instances.

Returns:
true if this control type causes the form to be submitted, otherwise false.

isSelect

public boolean isSelect()
Indicates whether this control type represents a select element.

Returns true only for the SELECT_SINGLE and SELECT_MULTIPLE instances.

This method is exactly equivalent to testing getTagName()==Tag.SELECT.

Returns:
true if this control type represents a select element, otherwise false.

get

public static FormControlType get(java.lang.String formControlTypeId)
Returns the FormControlType with the specified ID.

Parameters:
formControlTypeId - the ID of a form control type.
Returns:
the FormControlType with the specified ID, or null if no such control exists.
See Also:
getFormControlTypeId()

toString

public java.lang.String toString()
Returns a string which identifies this form control type.

This is equivalent to getFormControlTypeId().

Returns:
a string which identifies this form control type.

allowsMultipleValues

public boolean allowsMultipleValues()
Deprecated. Use the more useful FormField.allowsMultipleValues() method instead.

Indicates whether more than one control of this type with the same name can be successful.

Returns false only for the RADIO, SUBMIT, BUTTON, and IMAGE instances.

Note that before version 1.5 this method also returned false for the SELECT_SINGLE instance. This was a bug resulting from confusion as to whether each option element in a select element constituted a control (since it is possible for multiple options to be successful) or only the select element as a whole. The FormControl class now clearly defines the control as the entire select element, meaning that multiple SELECT_SINGLE controls with the same name will result in multiple values.

Because this may not be immediately intuitive, and the method is no longer used internally, this method has been deprecated as of version 1.5 to avoid any further confusion.

Returns:
true if more than one control of this type with the same name can be successful, otherwise false.

getAdditionalSubmitNames

public java.lang.String[] getAdditionalSubmitNames(java.lang.String name)
Deprecated. no replacement

Returns an array containing the additional field names submitted if a control of this type with the specified name is successful.

Returns null for all control types except IMAGE. It relates to the extra name.x and name.y data submitted when a pointing device is used to activate an IMAGE control.

This method has been deprecated as of version 1.5 as it is no longer used internally and was never very useful as a public method.

Parameters:
name - the name of a form control.
Returns:
an array containing the additional field names submitted if a control of this type with the specified name is successful, or null if none.

isPotentialControl

public static boolean isPotentialControl(java.lang.String tagName)
Deprecated. no replacement

Indicates whether an HTML tag with the specified name is potentially a form control.

Returns true if the specified tag name is one of "input", "textarea", "button" or "select" (ignoring case).

This method has been deprecated as of version 1.5 as it is no longer used internally and was never very useful as a public method.

Parameters:
tagName - the name of an HTML tag.
Returns:
true if an HTML tag with the specified name is potentially a form control, otherwise false.