|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.utexas.its.eis.tools.qwicap.servlet.Form
public final class Form
The Form
class provides a set of high-level utility methods for operating on the controls within an
XHTML "form" element.
If it looks like this class is implemented a lot like a large mass of procedural code, rather than as an
elegant hierarchy of classes representing the various types of form controls, you're right. And it's not by
accident. The elegant hierarchy of classes would be conceptually cleaner, probably easier to support, and more fun
to write, but it would also introduce assumptions into the code that the Form
class does not,
because building a set of control objects to represent the contents of a "form" element creates a
representation of the state of the form that is independent of the underlying markup. Which means that the
representation can become out-of-synch with the markup, if, for instance, the programmer prefers to do some
manipulation of form contents by directly using the templating engine, e.g.
MyMarkup.get("select[name='foo'] option[name='bar']").delete()
, or if the representation is retained
across prompt
invocations and Qwicap updates the form markup by embedding user-supplied values, etc.
In contrast, the Form
class maintains no state information about the form (other than the assumption
that the form still exists), so it can't become out-of-synch with the markup, programmers don't receive rude
surprises (so, no need for extra documentation, notes and warnings), and they remain free to choose the method of
manipulating the form markup that works best for them in any given situation (doing it directly, going through the
Form
class, or both). Put simply, the advantage of the Form
class as it is presently
constituted is that it is too dumb to die.
Finding, Examining, Transforming, and Deleting Controls:
deleteControl(Match, Object)
[static]deleteControl(String, Object)
getControl(String, Object)
getControlByIndex(String, int)
getControlByIndexAndValue(String, int, Object)
getControls(String, Object)
getControlsByName(String)
getControlName(Match)
[static]getSubmitControls()
convertSubmitButtonsToInputs()
convertSubmitInputsToButtons()
Control Value Related Methods:
addToControlValue(Match, Object)
[static]addToControlValue(String, Object)
clearControlValue(Match)
[static]clearControlValue(String)
clearControlValues(boolean)
getControlValue(Match)
[static]getControlValue(String)
getControlValues(Match)
[static]getControlValues(Match, boolean, boolean, boolean)
[static]getControlValues(String)
setControlValue(Match, Object)
[static]setControlValue(String, Object)
setControlValues(Object...)
Control State Related Methods:
enableControl(Match)
[static]enableControl(String)
enableControl(Match, Object)
[static]enableControl(String, Object)
enableControls(String...)
enableAllControls(boolean)
disableControl(Match)
[static]disableControl(String)
disableControl(Match, Object)
[static]disableControl(String, Object)
disableControls(String...)
disableAllControls(boolean)
isControlEnabled(Match)
[static]setControlEnable(Match, boolean)
[static]setControlEnable(String, boolean)
Control Group (Checkbox, Radio, Select) Related Methods:
addChoice(boolean, String, Object, boolean, String)
addFirstChoice(String, Object, boolean, String)
addLastChoice(String, Object, boolean, String)
addToControlValue(Match, Object)
[static]addToControlValue(String, Object)
createChoice(String, String, Object, boolean, String)
[static]deleteChoices(String)
Form Data Set Methods:
getAction()
getActionURL()
getCharacterSet()
setCharacterSet(java.lang.String)
getCharacterSets()
getDataSet()
getDataSet(boolean)
setDataSet(FormDataSet)
getMethod()
Form Utility Methods:
convertSubmitButtonsToInputs()
convertSubmitInputsToButtons()
get(String)
get(CSSPatterns)
getMatch()
toResults()
Debugging Methods:
Constructor Summary | |
---|---|
Form(Match TheForm)
Creates a Form object for operating on the specified form. |
|
Form(MutableMarkup ThePage,
FormDataSet DataSet)
Creates a Form object for manipulating the form that produced the supplied FormDataSet . |
Method Summary | |
---|---|
Results |
addChoice(boolean InsertBefore,
String ControlName,
Object ControlValue,
boolean Selected,
String Label)
Adds a choice to a pre-existing "select" control, group of radio buttons, or checkboxes. |
Results |
addFirstChoice(String ControlName,
Object ControlValue,
boolean Selected,
String Label)
Adds a new first choice to a pre-existing "select" control, group of radio buttons, or checkboxes. |
Results |
addLastChoice(String ControlName,
Object ControlValue,
boolean Selected,
String Label)
Adds a new last choice to a pre-existing "select" control, group of radio buttons, or checkboxes. |
static Match |
addToControlValue(Match Control,
Object ControlValue)
Adds to the value of a form control. |
Form |
addToControlValue(String ControlName,
Object ControlValue)
Adds to the value of a form control. |
static void |
clearControlValue(Match Control)
Clears the value of the supplied from control, even if it is of a type whose value cannot be altered by the user. |
Form |
clearControlValue(String ControlName)
Removes the value of the specified form control. |
Form |
clearControlValues(boolean AlsoClearDisabledControls)
Removes the values from the controls in this form whose values can be altered by the user. |
int |
convertSubmitButtonsToInputs()
Converts all "button" controls of type "submit" to "input" controls of type "submit", in order to work around a hideous bug in Internet Explorer (Windows and Mac OS). |
int |
convertSubmitInputsToButtons()
Converts all "input" controls of type "submit" that were "button" controls before convertSubmitButtonsToInputs() was invoked back into "button" controls of type "submit". |
static ImmutableMarkup |
createChoice(String Type,
String ControlName,
Object ControlValue,
boolean Selected,
String Label)
Creates the markup for a new choice ("option", "radio", or "checkbox"). |
Form |
deleteChoices(String ControlName)
Deletes all choices associated with the control of the specified name. |
static void |
deleteControl(Match Control,
Object ControlValue)
Deletes the specified control, if its value matches the specified value, or the specified value is null . |
Form |
deleteControl(String ControlName,
Object ControlValue)
Deletes the specified control, if its value matches the specified value, or the specified value is null . |
Form |
disableAllControls(boolean IncludesSubmitButtons)
Disables all controls in this form, optionally including even the "submit" button(s). |
static Match |
disableControl(Match Control)
Disables the specified control. |
static Match |
disableControl(Match Control,
Object ControlValue)
Disables the specified control, if its value matches the specified value, or the specified value is null . |
Form |
disableControl(String ControlName)
Disables the named control. |
Form |
disableControl(String ControlName,
Object ControlValue)
Disables the named control, if its value matches the specified value, or the specified value is null . |
Form |
disableControls(String... ControlNames)
Disables multiple form controls as identified by their names. |
Form |
enableAllControls(boolean IncludesSubmitButtons)
Enables all controls in this form, optionally including even the "submit" button(s). |
static Match |
enableControl(Match Control)
Enables the specified control. |
static Match |
enableControl(Match Control,
Object ControlValue)
Enables the specified control, if its value matches the specified value, or the specified value is null . |
Form |
enableControl(String ControlName)
Enables a form control identified by the name of the parameter that the control will submit in the form data set. |
Form |
enableControl(String ControlName,
Object ControlValue)
Enables the named control, if its value matches the specified value, or the specified value is null . |
Form |
enableControls(String... ControlNames)
Enables multiple form controls as identified by their names. |
Results |
get(CSSPatterns CSSPatterns)
Searches this "form" element, and its children, for matches with the specified CSS2 pattern(s). |
Results |
get(String CSSPatterns)
Searches this "form" element, and its children, for matches with the specified CSS2 pattern(s). |
String |
getAction()
Returns the value of the form's "action" attribute, or null if there is no such attribute. |
URL |
getActionURL()
Attempts to construct a fully-qualified action URL from the value of the form's "action" attribute, the URL of the page in which this form occurs, and any "base" element that the page may contain. |
String |
getCharacterSet()
Returns the first character set name from the list of character set names in the "form" element's "accept-charset" attribute. |
String[] |
getCharacterSets()
Returns the name of the character sets in which this form's data set may be encoded, based on the list in the "form" element's "accept-charset" attribute. |
FormControlInfo |
getControl(String ControlName,
Object ControlValue)
Returns a FormControlInfo object describing the specific form control that supplied, or could have
supplied, a particular name/value pair in a form data set. |
FormControlInfo |
getControlByIndex(String ControlName,
int ControlIndex)
Returns a FormControlInfo object describing the form control with the specified name (which is
understood to be shared with other controls in the form), and index number. |
FormControlInfo |
getControlByIndexAndValue(String ControlName,
int ControlIndex,
Object ControlValue)
Returns a FormControlInfo object describing the form control with the specified name (which is
understood to be shared with other controls in the form), index number, and value. |
static String |
getControlName(Match Control)
Returns the name of the specified control, or null if the control has no name. |
FormControlInfo[] |
getControls(String ControlName,
Object ControlValue)
Returns an array of FormControlValue objects describing the form controls that supplied, or could have
supplied, a particular name/value pair in a form data set. |
Results |
getControlsByName(String ControlName)
Finds the form controls having the specified name. |
edu.utexas.its.eis.tools.table.MutableTable |
getControlsTable()
A debugging method that produces a table of all controls in this form, the labels associated with them, and the value(s) of each control. |
static String |
getControlValue(Match Control)
Returns the value of the specified control as a String . |
String |
getControlValue(String ControlName)
Returns the current value of the named control as a String . |
static String[] |
getControlValues(Match Control)
Returns the value of the specified control as a String . |
static String[] |
getControlValues(Match Control,
boolean SuccessfulControlsOnly,
boolean IncludeSubmitControls,
boolean IncludeMisnomerValues)
Returns the value(s) of the specified control, optionally limiting the values to those supplied by the controls that will be successful by default. |
String[] |
getControlValues(String ControlName)
Returns the current value(s) of the named control as a String array. |
FormDataSet |
getDataSet()
Get the values of all of the enabled, successful controls in this form. |
FormDataSet |
getDataSet(boolean IncludeSolitarySubmitControl)
Get the values of all of the enabled, successful controls in this form. |
Match |
getMatch()
Returns the Match object that uniquely identifies the "form" element represented by this
Form object. |
String |
getMethod()
Returns the value of the form's "method" attribute ("get" or "post"), or null if there is no such attribute. |
FormControlInfo[] |
getSubmitControls()
Returns an array of FormControlValue objects describing the "submit" controls in this form. |
static boolean |
isControlEnabled(Match Control)
Returns true if the specified control is enabled, false otherwise. |
Form |
printAllLabels()
Deprecated. Use getControlsTable() instead. |
Form |
setCharacterSet(String CharacterSet)
Sets the character set in which the data set created by this form will be encoded. |
static Match |
setControlEnable(Match Control,
boolean Enable)
Enables or disables the specified control according to a boolean parameter. |
Form |
setControlEnable(String ControlName,
boolean Enable)
Enables or disables the named control according to a boolean parameter. |
static Match |
setControlValue(Match Control,
Object ControlValue)
Sets the value of a form control, identified by name. |
Form |
setControlValue(String ControlName,
Object ControlValue)
Sets the value of a form control, identified by name. |
Form |
setControlValues(Object... NameValuePairs)
Sets the value of multiple form controls, as identified by the names of the parameters the controls will submit. |
Form |
setDataSet(FormDataSet DataSet)
Takes the values of the supplied form data set, and writes them into this form, where applicable. |
Results |
toResults()
Creates Results object containing a reference to this "form" element. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Form(MutableMarkup ThePage, FormDataSet DataSet) throws FormNotFoundException
Form
object for manipulating the form that produced the supplied FormDataSet
.
ThePage
- The page of markup in which the form is to be found.DataSet
- The FormDataSet
that was produced by one of the forms on this page.
FormNotFoundException
- If the markup of this page does not contain a form that could have produced the
supplied FormDataSet
.public Form(Match TheForm) throws FormNotFoundException
Form
object for operating on the specified form.
TheForm
- The relevant "form" tag within that markup.
FormNotFoundException
- If the TheForm
does not refer to a "form" element.Method Detail |
---|
public String toString()
toString
in class Object
public Match getMatch()
Match
object that uniquely identifies the "form" element represented by this
Form
object.
Match
object that uniquely identifies the "form" element
represented by this Form
object.public String getAction()
null
if there is no such attribute.
null
if there is no such
attribute.public URL getActionURL() throws MalformedURLException
MalformedURLException
- If a potentially valid action URL could not be constructed.public String getMethod()
null
if there is no such attribute.
null
if there is no such
attribute.public Form setCharacterSet(String CharacterSet) throws TagException
CharacterSet
- The official IANA name of the
character set in which the form's data set will be encoded.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.public String getCharacterSet()
getCharacterSets()
public String[] getCharacterSets()
public Results get(String CSSPatterns)
Results
object returned is empty.
CSSPatterns
- One or more CSS2 patterns to be applied to this element and its children.
Results
object containing a list of elements that matched the specified
pattern(s), if any.public Results get(CSSPatterns CSSPatterns)
Results
object returned is empty.
CSSPatterns
- One or more CSS2 patterns to be applied to this element and its children.
Results
object containing a list of elements that matched the specified
pattern(s), if any.public Results toResults()
Results
object containing a reference to this "form" element.
Results
object containing a reference to this "form" element.public Form deleteChoices(String ControlName) throws TagException
addChoice
to build-up a
new list of choices to replace the ones you've deleted, because once an array of radio or checkbox buttons has
been deleted, there's no trace of them left in the markup. That's because the way HTML forms were designed, radio
and checkbox controls have no parent control to hold their place, unlike "select" controls which are parents to
all of the "option" controls that represent the choices they offer. So, don't use deleteChoices
on
"input" controls of types "radio" or "checkbox" unless you want to be rid of them, but feel free to use it on
"select" controls.
ControlName
- The name of the control whose associated choices should be deleted.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.public Results addFirstChoice(String ControlName, Object ControlValue, boolean Selected, String Label) throws TagException
ControlName
- Name of the control.ControlValue
- Value of this choice.Selected
- true
if the choice is selected by default.Label
- Human-interface label for the new choice.
Results
object that references the new choice control.
TagException
- If a problem is encountered with the manipulation of the markup.addChoice(boolean, String, Object, boolean, String)
,
addLastChoice(String, Object, boolean, String)
public Results addLastChoice(String ControlName, Object ControlValue, boolean Selected, String Label) throws TagException
ControlName
- Name of the control.ControlValue
- Value of this choice.Selected
- true
if the choice is selected by default.Label
- Human-interface label for the new choice.
Results
object that references the new choice control.
TagException
- If a problem is encountered with the manipulation of the markup.addFirstChoice(String, Object, boolean, String)
,
addChoice(boolean, String, Object, boolean, String)
public Results addChoice(boolean InsertBefore, String ControlName, Object ControlValue, boolean Selected, String Label) throws TagException
InsertBefore
- true
if the new choice should be inserted before the existing choices, or
false
if the new choice should be inserted after the existing choices.ControlName
- Name of the control.ControlValue
- Value of this choice.Selected
- true
if the choice is selected by default.Label
- Human-interface label for the new choice.
Results
object that references the new choice control.
TagException
- If a problem is encountered with the manipulation of the markup.addFirstChoice(String, Object, boolean, String)
,
addLastChoice(String, Object, boolean, String)
public static ImmutableMarkup createChoice(String Type, String ControlName, Object ControlValue, boolean Selected, String Label) throws TagException
Type
- The type of control to be created: "option", "radio", or "checkbox".ControlName
- Name of the control.ControlValue
- Value of this choice.Selected
- true
if the choice is selected by default.Label
- Human-interface label for the new choice.
ImmutableMarkup
object containing the markup for the new choice.
TagException
- If a problem is encountered with the manipulation of the markup.@Deprecated public Form printAllLabels()
getControlsTable()
instead.
Form
object.public edu.utexas.its.eis.tools.table.MutableTable getControlsTable()
MutableTable
object listing all of the controls in this form, and the labels associated with
them.public Results getControlsByName(String ControlName)
ControlName
- The name of the control to be searched-for.
public FormControlInfo getControlByIndex(String ControlName, int ControlIndex)
FormControlInfo
object describing the form control with the specified name (which is
understood to be shared with other controls in the form), and index number. In other words, it gets the Nth control
of the specified name from the form. The controls are considered in the order in which they occur in the markup,
with index 0 considered to be the first control.
ControlName
- Name of the parameter whose originating form control should be found.ControlIndex
- Index number of the originating form control.
FormControlInfo
instance describing the relevant form control, otherwise
null
.public FormControlInfo getControlByIndexAndValue(String ControlName, int ControlIndex, Object ControlValue)
FormControlInfo
object describing the form control with the specified name (which is
understood to be shared with other controls in the form), index number, and value. In other words, it gets the Nth
control of the specified name from the form, provided that the supplied value matches it, or some part of it. The
controls are considered in the order in which they occur in the markup, with index 0 considered to be the first
control.
ControlName
- Name of the parameter whose originating form control should be found.ControlIndex
- The index number of the originating form control.ControlValue
- The value whose originating form control should be found.
FormControlInfo
instance describing the relevant form control, otherwise
null
.public FormControlInfo getControl(String ControlName, Object ControlValue)
FormControlInfo
object describing the specific form control that supplied, or could have
supplied, a particular name/value pair in a form data set. Since groups of radio buttons and checkboxes consist of
sets of controls that all submit name/value pairs with the same name, this function has to match the value as well
in order to ensure that it returns the control specifically responsible for the value.
Note that a specific form control can't necessarily be identified from a control name and value, because some
controls (input for text and passwords, for example) have their values supplied client-side by the user, in other
words, they can't be identified because the value is not in the document markup. In such cases, the first (and
presumably the only) form control that supplies a parameter of the specified name is returned. This is also the
behavior when, for whatever reason, the supplied control value is null
.
ControlName
- Name of the parameter whose originating form control should be found.ControlValue
- Value of the parameter whose originating form control should be found. Can be
null
; see method description.
FormControlInfo
instance describing the relevant form control, otherwise
null
.public FormControlInfo[] getControls(String ControlName, Object ControlValue)
FormControlValue
objects describing the form controls that supplied, or could have
supplied, a particular name/value pair in a form data set. Since groups of radio buttons and checkboxes consist of
sets of controls that all submit values of the same name, this function has to match the value to ensure that it
returns the control specifically responsible for the value.
Note that a specific form control can't necessarily be identified from a control name and value, because some
controls (input for text and passwords, for example) have their values supplied client-side by the user, in other
words, they can't be identified because the value is not in the document markup. In such cases, all the form
controls of the specified name are returned. This is also the behavior when, for whatever reason, the supplied
control value is null
.
ControlName
- Name of the control.ControlValue
- Value of the control. Can be null
; see method description.
FormControlInfo
instances describing the relevant form controls,
or an empty array if no relevant form controls could be found.public FormControlInfo[] getSubmitControls()
FormControlValue
objects describing the "submit" controls in this form.
public Form addToControlValue(String ControlName, Object ControlValue) throws TagException
setControlValue(String, Object)
, but it's a single-value control, so we have
no choice). In the case of "input" controls of type "checkbox", the control with the specified value is located and
selected ("checked"). In the case of "input" controls of type "radio", the control with the specified value
is located and selected ("checked"), and all of the other controls are de-selected (their "checked" attributes are
deleted). Where those radio buttons are concerned, this method is no different from calling
setControlValue(String, Object)
, but a group of radio buttons can represent only one value, so we have no
choice.
ControlName
- The name of a form control of type "input", "select", "textarea" or "button".ControlValue
- Value of the form control.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.public static Match addToControlValue(Match Control, Object ControlValue) throws TagException
setControlValue(Match, Object)
, but it's a single-value control, so we have
no choice). In the case of an "input" control of type "checkbox", the control is selected ("checked") if its value
matches the specified value, and it is left untouched otherwise. In the case of an "input" control of type "radio",
the control is selected ("checked") if its value matches the specified value, and it is unselected (its "checked"
attribute is deleted) otherwise.
Control
- A Match
instance that refers to an "input", "select", "textarea" or
"button" control.ControlValue
- Value of the form control.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.public Form setControlValue(String ControlName, Object ControlValue) throws TagException
setControlValue
invocation by passing an array of values to be
selected as the ControlValue
parameter. The array elements may be of any type; the
toString
methods of the non-null elements will be invoked, and the controls whose values match the
returned String
s (if any) will be checked/selected. Alternately, if you prefer to set the values of
multi-value controls by using multiple method invocations, start by invoking clearControlValue(String)
to
remove all pre-existing checks/selects, then use invocations of addToControlValue(String, Object)
to
check/select as many items as necessary. For single-value controls, this setControlValue
method is
always appropriate.
ControlName
- Name of the form control.ControlValue
- Value of the form control. If null
, the value of the control is cleared
with the clearControlValue(Match)
method. If the value is an array, and the
control supports multiple values, the control is given each of the values in the array.
The array may be of any type; its elements are converted to strings using their
toString
methods.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.addToControlValue(String, Object)
,
clearControlValue(String)
public static Match setControlValue(Match Control, Object ControlValue) throws TagException
setControlValue
invocation by passing an array of values to be
selected as the ControlValue
parameter. The array elements may be of any type; the
toString
methods of the non-null elements will be invoked, and the controls whose values match the
returned String
s (if any) will be checked/selected. Alternately, if you prefer to set the values of
multi-value controls by using multiple method invocations, start by invoking clearControlValue(String)
to
remove all pre-existing checks/selects, then use invocations of addToControlValue(String, Object)
to
check/select as many items as necessary. For single-value controls, this setControlValue
method is
always appropriate.
Control
- A Match
object corresponding to a tag of type "input", "select",
"textarea", or "button".ControlValue
- Value of the form control. If null
, the value of the control is cleared
with the clearControlValue(Match)
method. If the value is an array, and the
control supports multiple values, the control is given each of the values in the array.
The array may be of any type; its elements are converted to strings using their
toString
methods.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.addToControlValue(String, Object)
,
clearControlValue(String)
public Form setControlValues(Object... NameValuePairs) throws TagException
clearControlValue(String)
to remove all pre-existing checks/selects, then use invocations of
addToControlValue(String, Object)
to check/select as many items as necessary. This setControlValues
method is appropriate for all other form controls, including radio buttons and single-selection lists.
NameValuePairs
- An array composed of control name/value pairs such that the even-numbered elements
are the names of controls, and the odd-numbered elements are the values, e.g.
"name1", "value1", "name2", "value2", "name3", "value3". The values may be of any type
(they will ultimately be converted to String
s using their
toString
methods). If a value is null
, the value of the
control is cleared with the clearControlValue(Match)
method. If a value is an
array, the control is given all the values specified by the array. (The array may be of
any type; it's elements are converted to strings using their
toString
methods.) The control names in the even-numbered elements of this
parameter will ordinarily be String
s, but can actually be of any type (as
with values, their toString
methods are invoked).
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.public Form enableAllControls(boolean IncludesSubmitButtons) throws TagException
IncludesSubmitButtons
- true
if all submit buttons in this form should also be enabled,
false
otherwise.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.public Form disableAllControls(boolean IncludesSubmitButtons) throws TagException
IncludesSubmitButtons
- true
if all submit buttons in this form should also be disabled,
false
otherwise.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.public Form setControlEnable(String ControlName, boolean Enable) throws TagException
boolean
parameter.
ControlName
- Name of the form control.Enable
- true
if the control should be enabled, false
if it should be
disabled.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.enableControl(String)
,
disableControl(String)
public static Match setControlEnable(Match Control, boolean Enable) throws TagException
boolean
parameter.
Control
- A Match
object corresponding to a tag of type "input", "select",
"textarea", or "button".Enable
- true
if the control should be enabled, false
if it should be
disabled.
TagException
- If a problem is encountered with the manipulation of the markup.public Form enableControl(String ControlName) throws TagException
enableControl(String, Object)
method.) Note that "enabling"
means nothing more than deleting the "disabled" attribute from applicable form controls.
ControlName
- Name of the form control.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.enableControl(String, Object)
,
Forms in HTML Documents, sec. 17.12.1, Disabled controlspublic Form enableControls(String... ControlNames) throws TagException
enableControl(String, Object)
method.) Note that "enabling" means nothing
more than deleting the "disabled" attribute from applicable form controls.
ControlNames
- The names of the form controls to enable.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.enableControl(String)
,
Forms in HTML Documents, sec. 17.12.1, Disabled controlspublic Form enableControl(String ControlName, Object ControlValue) throws TagException
null
. In the case of checkboxes, radio buttons, and "select" controls, the parameter value is used in
addition to the name to identify the relevant form control. In all other cases the value may be omitted. (Note that
"enabling" means nothing more than removing the "disabled" attribute from applicable form controls, if present.)
ControlName
- Name of the form control.ControlValue
- Value of the form control, or null
. The value is only needed when
enabling specific items in multiple selection controls (checkboxes, radio buttons, and
"select" controls). When dealing with those controls, passing null
in
this parameter causes all selections in the group to be enabled.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.public static Match enableControl(Match Control, Object ControlValue) throws TagException
null
.
Control
- A Match
object corresponding to a tag of type "input", "select",
"textarea", or "button".ControlValue
- The value the control must have in order to be enabled, or null
if it
should be enabled regardless of its value.
TagException
- If a problem is encountered with the manipulation of the markup.public Form disableControl(String ControlName) throws TagException
disableControl(String, Object)
method.) Note that "disabling" means nothing more than adding the "disabled"
attribute to applicable form controls.
ControlName
- Name of the form control to disable.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.disableControl(String, Object)
,
Forms in HTML Documents, sec. 17.12.1, Disabled controlspublic Form disableControls(String... ControlNames) throws TagException
disableControl(String, Object)
method.) Note that "disabling" means nothing
more than adding the "disabled" attribute to applicable form controls.
ControlNames
- The names of the form controls to disable.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.disableControl(String)
,
Forms in HTML Documents, sec. 17.12.1, Disabled controlspublic Form disableControl(String ControlName, Object ControlValue) throws TagException
null
. In the case of checkboxes, radio buttons, and "select" controls, the control value is used in
addition to the name to identify the relevant form control. In all other cases the value may be omitted. (Note that
"disabling" means nothing more than adding the "disabled" attribute to applicable form controls.)
ControlName
- Name of the form control.ControlValue
- Value of the form control, or null
. The value is only needed when
disabling specific items in multiple selection controls (checkboxes, radio buttons, and
"select" controls). When dealing with those controls, passing null
in
this parameter causes all selections in the group to be disabled.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.public static Match disableControl(Match Control, Object ControlValue) throws TagException
null
.
Control
- A Match
object corresponding to a tag of type "input", "select",
"textarea", or "button".ControlValue
- The value the control must have in order to be disabled, or null
if it
should be disabled regardless of its value.
TagException
- If a problem is encountered with the manipulation of the markup.public Form deleteControl(String ControlName, Object ControlValue) throws TagException
null
.
ControlName
- Name of the form control.ControlValue
- Value of the form control, or null
. The value is only needed when
deleting specific items in multiple selection controls (checkboxes, radio buttons, and
"select" controls). When dealing with those controls, passing null
in
this parameter causes all selections in the group to be deleted.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.public static void deleteControl(Match Control, Object ControlValue) throws TagException
null
.
Control
- A Match
object corresponding to a tag of type "input", "select",
"textarea", or "button".ControlValue
- The value the control must have in order to be deleted, or null
if it
should be deleted regardless of its value.
TagException
- If a problem is encountered with the manipulation of the markup.public FormDataSet getDataSet()
public FormDataSet getDataSet(boolean IncludeSolitarySubmitControl)
IncludeSolitarySubmitControl
parameter is false
the values of all submit control(s) are omitted. If the
IncludeSolitarySubmitControl
parameter is true
, and there's only one submit control, its
value is included, but if there are multiple "submit" controls, all of their values are omitted, because we cannot
know which one the user would have picked.
IncludeSolitarySubmitControl
- If true
and the form includes only one "submit" control, the value
of that control is included in the data set. If false
, all
"submit" contorls are ignored.
public Form setDataSet(FormDataSet DataSet) throws TagException
DataSet
- The form data set to be written into this form.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.public Form clearControlValues(boolean AlsoClearDisabledControls) throws TagException
AlsoClearDisabledControls
- If true
, the values of disabled controls of any type are also
cleared. Otherwise, the values of disabled controls are left as they are.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.public Form clearControlValue(String ControlName) throws TagException
ControlName
- Name of the form control.
Form
object.
TagException
- If a problem is encountered with the manipulation of the markup.public static void clearControlValue(Match Control) throws TagException
Control
- A Match
object corresponding to a tag of type "input", "select",
"textarea", or "button".
TagException
- If a problem is encountered with the manipulation of the markup.public static String getControlName(Match Control)
null
if the control has no name.
Control
- A Match
object corresponding to a tag of type "input", "select",
"textarea", or "button".
null
if the control has no name.public String getControlValue(String ControlName)
String
. If the control has more than one value,
this method will only return the first; use getControlValues(String)
for multi-value controls. If the
control has no value, or would not be successful,
null
is returned.
ControlName
- The name of the control whose value should be retrieved.
null
if the control does not exist, has no
value, or would be unsuccessful.public String[] getControlValues(String ControlName)
String
array. If the control has no
values (maybe it is a group of radio buttons and none are selected), a zero-length array is returned. The exceptions
to that rule are "input" controls of type "text" and "password", because without a value they will submit an empty
string, so this method returns an empty string in their case. In other words, this method differentiates between
successful and unsuccessful
controls; returning null
for a control that would be unsuccessful as it stands; returning an empty
array for a control that would be successful, but has no value; and returning an array of one or more values for a
control that would be successful and has one or more values.
ControlName
- The name of the control whose value(s) should be retrieved.
null
if the control does not exist, or
would be unsuccessful.public static String getControlValue(Match Control)
String
. If the control has more than one value,
this method will only return the first; use getControlValues(Match)
for multi-value controls. (In the
context of this method, which can only operate on an individual control element, only a "select" control can have
multiple values. To avoid that limitation, use getControlValue(String)
.) If the control has no value (maybe
it is a "select" control with none of its "option" elements selected), null
is returned. The exceptions
to that rule are "input" controls of type "text" and "password", because without a value they will submit an empty
string, so this method returns an empty string in their case. In other words, this method differentiates between
successful and unsuccessful
controls; returning null
for a control that would be unsuccessful as it stands; returning an empty
array for a control that would be successful, but has no value; and returning an array of one or more values for a
control that would be successful and has one or more values.
Control
- A Match
object corresponding to a tag of type "input", "select",
"option", "textarea", or "button".
null
if the control does not exist, or
has no value.public static String[] getControlValues(Match Control)
String
. If the control has more than one value,
this method will only return the first; use getControlValues(Match)
for multi-value controls. (In the
context of this method, which can only operate on an individual control element, only a "select" control can have
multiple values. To avoid that limitation, use getControlValue(String)
.) If the control has no value (maybe
it is a "select" control with none of its "option" elements selected), null
is returned. The exceptions
to that rule are "input" controls of type "text" and "password", because without a value they will submit an empty
string, so this method returns an empty string in their case. In other words, this method differentiates between
successful and unsuccessful
controls; returning null
for a control that would be unsuccessful as it stands; returning an empty
array for a control that would be successful, but has no value; and returning an array of one or more values for a
control that would be successful and has one or more values.
Control
- A Match
object corresponding to a tag of type "input", "select",
"option", "textarea", or "button".
null
if the control would be
unsuccessful.public static String[] getControlValues(Match Control, boolean SuccessfulControlsOnly, boolean IncludeSubmitControls, boolean IncludeMisnomerValues)
Control
- A Match
object corresponding to a tag of type "input", "select",
"option", "textarea", or "button".SuccessfulControlsOnly
- If true
, only controls that would supply values (be successful) if a
user were to submit the form as-is are allowed to contribute values to the list of
values that is returned. If false
, all controls supply their values.IncludeSubmitControls
- If true
, the value(s) of submit button(s) (either "input" or "button"
controls of type "submit"), are included in the list of values that is returned.
If false
they are omitted.IncludeMisnomerValues
- If true
, the values of "input" controls of type "file" are returned.
The real value of such controls can't be determined server-side, because the real
value of the control is the content of the file, if any, that the user selects.
However, such controls do have a "value" attribute which specifies the default name
of the file on the client machine that is to be uploaded. For lack of a better name,
I call that default file name in the "value" attribute a "misnomer value".
String
s, containing zero or more elements, representing
the value(s) of the specified control. If the control has no value, the array is
empty.public static boolean isControlEnabled(Match Control)
true
if the specified control is enabled, false
otherwise.
Control
- A Match
instance that refers to an "input", "select", "textarea" or
"button" control.
true
if the specified control is enabled, false
otherwise.public static Match disableControl(Match Control) throws TagException
Control
- A Match
instance that refers to an "input", "select", "textarea",
"button", "option", or "optgroup" tag.
TagException
- If a problem is encountered with the manipulation of the markup.public static Match enableControl(Match Control) throws TagException
Control
- A Match
instance that refers to an "input", "select", "textarea",
"button", "option", or "optgroup" tag.
TagException
- If a problem is encountered with the manipulation of the markup.public int convertSubmitButtonsToInputs() throws TagException
TagException
- If a problem is encountered with the manipulation of the markup.public int convertSubmitInputsToButtons() throws TagException
convertSubmitButtonsToInputs()
was invoked back into "button" controls of type "submit". In other words,
this method undoes what convertSubmitButtonsToInputs()
does.
TagException
- If a problem is encountered with the manipulation of the markup.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |