net.sf.jolene.dom
Class Form

java.lang.Object
  extended by net.sf.jolene.dom.HTMLElement
      extended by net.sf.jolene.dom.Form
All Implemented Interfaces:
java.lang.Cloneable, IAttributes, ICollection, IStyles

public final class Form
extends HTMLElement

A form in a html document. This acts as a container for other html objects.

Since:
Oct 21, 2003
Author:
Dan Howard

Method Summary
 Form clone()
          Core clone implementation.
 HTMLElement elements(int element)
          This method returns the widget specified by the numeric index.
 HTMLElement elements(java.lang.String elementName)
          This method retrieves an object from the document by name or id.
 int getElementCount()
           
 Grid getGrid(java.lang.String name)
          Returns the specified element casted to a Grid object.
 java.util.Map<java.lang.String,HTMLElement> getRadioGroup(java.lang.String groupName)
          Returns a Map of Radio objects based the specified radio group name.
 Select getSelect(java.lang.String name)
          Returns the specified element casted to a Select object.
 boolean hasElement(java.lang.String name)
          Checks if the specified object exists in the form.
 void populate(java.util.Map<java.lang.String,java.lang.String> map)
          Populates the form object from the supplied map object.
 void populate(java.lang.Object bean)
          Poplates the form objects based on the supplied java bean.
 
Methods inherited from class net.sf.jolene.dom.HTMLElement
clear, getAfterText, getAttribute, getBeforeText, getContent, getName, getStyle, getTag, getValue, hasAttribute, hasStyle, isChecked, isDisabled, isReadonly, isRenderable, keySet, removeAttribute, removeStyle, resetStyles, resetStyles, setAfterText, setAttribute, setBeforeText, setChecked, setContent, setDisabled, setName, setReadonly, setRenderable, setStyle, setStyles, setStyles, setValue, swapWith, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

clone

public Form clone()
Description copied from class: HTMLElement
Core clone implementation. Safely clones HTMLElement objects. Used by the DocumentFactory.

Overrides:
clone in class HTMLElement
Returns:
HTMLElement
See Also:
DocumentFactory

elements

public HTMLElement elements(int element)
This method returns the widget specified by the numeric index. The prefered way of retrieving an object from the form is to use it's name or id instead since the order of the objects can be changed easily by a page designer.

Parameters:
element - - The integer element number of the object desired.
Returns:
HTMLElement

elements

public HTMLElement elements(java.lang.String elementName)
This method retrieves an object from the document by name or id. When the document is opened it creates objects by looking at the ID attribute first. If that attribute doesn't exist it uses the NAME attribute. If neither exist then the only way to address these objects is by number (not recommended).
This method returns the base HTMLElement object so if you want a Select or Grid object you can either cast it:
 Grid grid grid = (Grid)document.forms(0).elements("Grid1");
 
or use the appropriate getter:
 Grid grid = document.forms(0).getGrid("Grid1");
 

Parameters:
elementName - - The string name or id of the object desired.
Returns:
HTMLElement or null if not found or elementName is null.

getElementCount

public int getElementCount()
Returns:
Number of elements in the form.

getGrid

public Grid getGrid(java.lang.String name)
Returns the specified element casted to a Grid object.

Parameters:
name - name of grid
Returns:
Grid

getRadioGroup

public java.util.Map<java.lang.String,HTMLElement> getRadioGroup(java.lang.String groupName)
Returns a Map of Radio objects based the specified radio group name. The map's order is insertion-order.

Parameters:
groupName - of radios
Returns:
Map

getSelect

public Select getSelect(java.lang.String name)
Returns the specified element casted to a Select object.

Parameters:
name - name of select
Returns:
Select

hasElement

public boolean hasElement(java.lang.String name)
Checks if the specified object exists in the form.

Parameters:
name - name to check
Returns:
boolean

populate

public void populate(java.lang.Object bean)
              throws FormPolulateException
Poplates the form objects based on the supplied java bean.

Parameters:
bean - any object which can be examined by BeanUtils.
Throws:
FormPolulateException - if BeanUtils fails.

populate

public void populate(java.util.Map<java.lang.String,java.lang.String> map)
Populates the form object from the supplied map object.

Parameters:
map - - name/values where names match element names