Class java.servlet.html.HtmlForm
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.servlet.html.HtmlForm

java.lang.Object
   |
   +----java.servlet.html.HtmlContainer
           |
           +----java.servlet.html.HtmlForm

public class HtmlForm
extends HtmlContainer
Collection of convenience methods for generating an html form.

Constructor Index

 o HtmlForm(String, String)
Create a form with references the given action and method.

Method Index

 o addCheckBox(String, String)
Adds a check box to the form.
 o addCheckBox(String, String, boolean)
Adds a single checkbox to the form.
 o addChoice(HtmlChoice)
 o addChoice(String, String)
adds a multiple choice element to this form with options from the specified array of values To better control the options use addChoice(HtmlChoice choice);
 o addChoice(String, String, String)
adds a multiple choice element to this form with options from the specified array of values.
 o addHiddenField(String, String)
Adds a hidden field to the form with the given name and value.
 o addImageButton(String, String)
adds an image button to this form equivalent to addTag("input type=image src=" + src + " name=" + name);
 o addImageButton(String, String, String)
adds an image button to this form equivalent to addTag("input type=image src=" + src + " name=" + name + ' ' + attribs);
 o addPasswordField(String)
Adds a password field with the given name to the form.
 o addPasswordField(String, String)
Adds a password field with the given name and other attributes to the form.
 o addRadioButton(String, String)
Adds a radio button to the form.
 o addRadioButton(String, String, boolean)
Adds a single radio button field to the form with the given name and value.
 o addResetButton()
adds a reset button to this form equivalent to addTag("input type=reset");
 o addResetButton(String)
adds a reset button to this form equivalent to addTag("input type=reset " + attribs);
 o addSubmitButton()
adds a submit button to this form equivalent to addTag("input type=submit");
 o addSubmitButton(String)
adds a submit button to this form equivalent to addTag("input type=submit " + attribs);
 o addTextArea(String)
Adds a text area to the form.
 o addTextArea(String, String)
Adds a text area to the form.
 o addTextArea(String, String, String)
Adds a text area to the form.
 o addTextField(String)
Adds a text field with the given name to the form.
 o addTextField(String, String)
adds a text field with the given name and other attributes to this form.

Constructors

 o HtmlForm
  public HtmlForm(String url,
                  String method)
Create a form with references the given action and method.
Parameters:
url - The action URL for the form.
method - The method the form uses to perform the action (GET, POST).

Methods

 o addHiddenField
  public void addHiddenField(String name,
                             String value)
Adds a hidden field to the form with the given name and value. is equivalent to addTag("input", "type=hidden name=" + name + " value=" + value);
Parameters:
name - The name of the hidden field.
value - The value of the hidden field.
 o addTextField
  public void addTextField(String name)
Adds a text field with the given name to the form. is equivalent to addTag(input, "type=text name=" + name)
 o addTextField
  public void addTextField(String name,
                           String attribs)
adds a text field with the given name and other attributes to this form. Is equivalent to: addTag("input", "type=text name=" + name + ' ' + attribs) ie. the code: addTextField("name", "size=30 maxlength=30 value=Your name here"); would add this line to the html document <input type=text name=name size=30 maxlength=30 value=Your name here>
 o addPasswordField
  public void addPasswordField(String name)
Adds a password field with the given name to the form. a password field is identical to a text field except that the the browser echo's some mask character to the user when they type instead of the text that they type. is equivalent to addTag("input", "type=password name=" + name);
 o addPasswordField
  public void addPasswordField(String name,
                               String attribs)
Adds a password field with the given name and other attributes to the form. is equivalent to addTag("input", "type=password name=" + name + ' ' + attribs);
Parameters:
name - Name of the field.
attribs - Other attributes of the field.
 o addCheckBox
  public void addCheckBox(String name,
                          String value)
Adds a check box to the form. equivalent to: addTag("input", "type=checkbox name=" + name + " value=" + value);
Parameters:
name - Name of the checkbox.
value - Value for this checkbox.
 o addCheckBox
  public void addCheckBox(String name,
                          String value,
                          boolean checked)
Adds a single checkbox to the form.
Parameters:
name - The name of this checkbox.
value - Value for this check box.
checked - Sets the checked attribute if true.
 o addRadioButton
  public void addRadioButton(String name,
                             String value)
Adds a radio button to the form. Multiple radio buttons added with the same name are interpreted by the browser to be in the same group and only one of them can be checked at any given time. equivalent to: addTag("input", "type=radio name=" + name + " value=" + value);
Parameters:
name - The name of this group of radio buttons.
value - Comma delimmited list of values for radio buttons in this group.
 o addRadioButton
  public void addRadioButton(String name,
                             String value,
                             boolean checked)
Adds a single radio button field to the form with the given name and value.
Parameters:
name - The group to add this radio button to.
value - The value of this radio button.
checked - Sets the checked attribute if true.
 o addTextArea
  public void addTextArea(String name)
Adds a text area to the form. This is equivalent to: add("", "textarea name=" + name);
Parameters:
name - The name of the textarea.
 o addTextArea
  public void addTextArea(String name,
                          String attribs)
Adds a text area to the form.
Parameters:
name - the name of the textarea
attribs - other attributes of the textarea is equivalent to: add("", "textarea name=" + name + ' ' + attribs);
 o addTextArea
  public void addTextArea(String name,
                          String attribs,
                          String def)
Adds a text area to the form.
Parameters:
name - the name of the textarea
attribs - other attributes of the textarea
def - the default text to put in the text area is equivalent to: add("", "textarea name=" + name + ' ' + attribs + " value" + def);
 o addChoice
  public void addChoice(String name,
                        String choices)
adds a multiple choice element to this form with options from the specified array of values To better control the options use addChoice(HtmlChoice choice);
Parameters:
name - the name attribute for the select tag
choices - comma delimmited list of choices for this element.
 o addChoice
  public void addChoice(String name,
                        String attribs,
                        String choices)
adds a multiple choice element to this form with options from the specified array of values. To better control the options use addChoice(HtmlChoice choice);
Parameters:
name - the name attribute for the select tag
attribs - other attributes of the select tag
choices - comma delimmited list of choices for this element.
 o addChoice
  public void addChoice(HtmlChoice choice)
Parameters:
choice - the HtmlChoice Element to add to this form.
 o addSubmitButton
  public void addSubmitButton()
adds a submit button to this form equivalent to addTag("input type=submit");
 o addSubmitButton
  public void addSubmitButton(String attribs)
adds a submit button to this form equivalent to addTag("input type=submit " + attribs);
Parameters:
attribs - other attributes for this submit button, ie. name & value
 o addResetButton
  public void addResetButton()
adds a reset button to this form equivalent to addTag("input type=reset");
 o addResetButton
  public void addResetButton(String attribs)
adds a reset button to this form equivalent to addTag("input type=reset " + attribs);
Parameters:
attribs - other attributes for this submit button, ie. name & value
 o addImageButton
  public void addImageButton(String src,
                             String name)
adds an image button to this form equivalent to addTag("input type=image src=" + src + " name=" + name);
Parameters:
src - the url to the image for this button
name - the name of this image button
 o addImageButton
  public void addImageButton(String src,
                             String name,
                             String attribs)
adds an image button to this form equivalent to addTag("input type=image src=" + src + " name=" + name + ' ' + attribs);
Parameters:
src - the url to the image for this button
name - the name of this image button
attribs - other attributes for this tag

All Packages  Class Hierarchy  This Package  Previous  Next  Index