SimpleServlets v5.5.0

com.simpleservlets.htmlobjects
Class HTMLSimpleForm

java.lang.Object
  extended by com.simpleservlets.htmlobjects.GenericHTMLElement
      extended by com.simpleservlets.htmlobjects.NoTagHTMLElement
          extended by com.simpleservlets.htmlobjects.HTMLSimpleForm
All Implemented Interfaces:
DoNotMinimizeEmpty, HTMLElement, NoAttributesAllowed, NoTag

public class HTMLSimpleForm
extends NoTagHTMLElement

Creates a two-column form. Generally the labels are in the left-hand column and the components are in the right-hand column. Nested within the form is a table.

For example, this code snippet:

 HTMLSimpleForm form = new HTMLSimpleForm(req.getRequestURI());
 form.addText("Username:", "user", "", 10);
 form.addPassword("Password:", "pass", "", 10);
 form.addSubmit("send.action", "Send");
 
very conveniently produces all this HTML output (without forgetting to close one tag and without forgetting to use all those quotes!):
 <form action="/HTMLObjectsDemo/go" method="post">
  <table border="0" cellspacing="1" cellpadding="2">
   <tr>
    <td align="right" valign="top">Username:</td>
    <td align="left" valign="top">
     <input type="text" name="user" size="10" />
    </td>
   </tr>
   <tr>
    <td align="right" valign="top">Password:</td>
    <td align="left" valign="top">
     <input type="password" name="pass" size="10" />
    </td>
   </tr>
   <tr>
    <td> </td>
    <td align="left" valign="top">
     <input type="submit" name="send.action" value="Send" />
    </td>
   </tr>
  </table>
 </form>
 

Author:
Paul Hyde

Field Summary
static AnchorPoint DEFAULT_LEFT_ANCHOR_POINT
          If no specific AnchorPoint is requested for the left-hand column, this will be used.
static AnchorPoint DEFAULT_RIGHT_ANCHOR_POINT
          If no specific AnchorPoint is requested for the right-hand column, this will be used.
 
Fields inherited from interface com.simpleservlets.htmlobjects.HTMLElement
ZERO_LEN_ARRAY
 
Constructor Summary
HTMLSimpleForm(String actionURL)
          Creates a two-column form aligned internally by a table.
 
Method Summary
 HTMLForm.Input addCheckBox(String label, String name, String value, boolean checked)
           
 HTMLForm.Input addHidden(String name, String value)
           
 HTMLForm.Input addImage(String name, String value, String imageSrc)
           
 HTMLForm.Input addPassword(String label, String name, String value, int size)
           
 HTMLForm.Input[] addRadioButtons(String label, String name, String[] value, String selectedValue)
           
 HTMLTable.Row addRow(HTMLElement left, HTMLElement right)
           
 HTMLTable.Row addRow(HTMLElement left, String text)
           
 HTMLTable.Row addRow(String label, double value)
           
 HTMLTable.Row addRow(String label, HTMLElement right)
           
 HTMLTable.Row addRow(String label, int value)
           
 HTMLTable.Row addRow(String label, Object value)
           
 HTMLTable.Row addRow(String label, String value)
           
 HTMLForm.Select addSelect(String label, String name, int visibleSize, boolean allowMultipleSelections, String[] value, String selectedValue, String firstLine)
           
 HTMLForm.Select addSelect(String label, String name, String[] value)
           
 HTMLForm.Select addSelect(String label, String name, String[] value, String selectedValue, String firstLine)
           
 HTMLForm.Input addSubmit(String name, String value)
           
 HTMLForm.Input addText(String label, String name, String value, int size)
           
 HTMLForm getForm()
           
 AnchorPoint getLeftAnchorPoint()
           
 AnchorPoint getRightAnchorPoint()
           
 HTMLTable getTable()
           
 void setLeftAnchorPoint(AnchorPoint leftAnchorPoint)
           
 void setRightAnchorPoint(AnchorPoint rightAnchorPoint)
           
 
Methods inherited from class com.simpleservlets.htmlobjects.GenericHTMLElement
add, add, addSibling, addSibling, getAttributes, getChildren, getName, getParent, hasAttributes, hasChildren, isSafeToWrapWithWhitespace, removeAllAttributes, removeAllChildren, removeAttribute, removeChild, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeGroup, setParent, setSafeToWrapWithWhitespace, setStyle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.simpleservlets.htmlobjects.HTMLElement
add, add, addSibling, addSibling, getAttributes, getChildren, getName, getParent, hasAttributes, hasChildren, isSafeToWrapWithWhitespace, removeAllAttributes, removeAllChildren, removeAttribute, removeChild, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeGroup, setParent, setStyle
 

Field Detail

DEFAULT_LEFT_ANCHOR_POINT

public static final AnchorPoint DEFAULT_LEFT_ANCHOR_POINT
If no specific AnchorPoint is requested for the left-hand column, this will be used. Value is AnchorPoint.NORTHEAST.


DEFAULT_RIGHT_ANCHOR_POINT

public static final AnchorPoint DEFAULT_RIGHT_ANCHOR_POINT
If no specific AnchorPoint is requested for the right-hand column, this will be used. Value is AnchorPoint.NORTHWEST.

Constructor Detail

HTMLSimpleForm

public HTMLSimpleForm(String actionURL)
Creates a two-column form aligned internally by a table. Default is to use the "post" method, use getForm() to access the internal form to change to the "get" method if needed.

Method Detail

addRow

public HTMLTable.Row addRow(HTMLElement left,
                            HTMLElement right)

addRow

public HTMLTable.Row addRow(String label,
                            HTMLElement right)

addRow

public HTMLTable.Row addRow(HTMLElement left,
                            String text)

addRow

public HTMLTable.Row addRow(String label,
                            String value)

addRow

public HTMLTable.Row addRow(String label,
                            Object value)

addRow

public HTMLTable.Row addRow(String label,
                            double value)

addRow

public HTMLTable.Row addRow(String label,
                            int value)

addSubmit

public HTMLForm.Input addSubmit(String name,
                                String value)

addImage

public HTMLForm.Input addImage(String name,
                               String value,
                               String imageSrc)

addHidden

public HTMLForm.Input addHidden(String name,
                                String value)

addText

public HTMLForm.Input addText(String label,
                              String name,
                              String value,
                              int size)

addPassword

public HTMLForm.Input addPassword(String label,
                                  String name,
                                  String value,
                                  int size)

addCheckBox

public HTMLForm.Input addCheckBox(String label,
                                  String name,
                                  String value,
                                  boolean checked)

addRadioButtons

public HTMLForm.Input[] addRadioButtons(String label,
                                        String name,
                                        String[] value,
                                        String selectedValue)

addSelect

public HTMLForm.Select addSelect(String label,
                                 String name,
                                 int visibleSize,
                                 boolean allowMultipleSelections,
                                 String[] value,
                                 String selectedValue,
                                 String firstLine)

addSelect

public HTMLForm.Select addSelect(String label,
                                 String name,
                                 String[] value,
                                 String selectedValue,
                                 String firstLine)

addSelect

public HTMLForm.Select addSelect(String label,
                                 String name,
                                 String[] value)

getForm

public HTMLForm getForm()

getTable

public HTMLTable getTable()

getLeftAnchorPoint

public AnchorPoint getLeftAnchorPoint()

setLeftAnchorPoint

public void setLeftAnchorPoint(AnchorPoint leftAnchorPoint)

getRightAnchorPoint

public AnchorPoint getRightAnchorPoint()

setRightAnchorPoint

public void setRightAnchorPoint(AnchorPoint rightAnchorPoint)

SimpleServlets v5.5.0

Copyright © 2001-2007 Programix Incorporated. All rights reserved. SimpleServlets is free and is OSI Certified Open Source Software under the BSD license.