net.sf.colle.forms
Class FormSet

java.lang.Object
  extended bynet.sf.colle.forms.FormSet
All Implemented Interfaces:
FormElement

public abstract class FormSet
extends Object
implements FormElement

Manages a finite set of information the user can choose from. Often displayed in a set of checkboxes or a drop list. Created: 10 Jul 2001

Version:
$Revision: 1.3 $, $Date: 2004/01/05 22:40:24 $
Author:
Jeremy Miller

Field Summary
 
Fields inherited from interface net.sf.colle.forms.FormElement
ERROR_INVALID, ERROR_REQUIRED, UNKNOWN, VALID
 
Constructor Summary
FormSet(String psName, Object pxApplicationElement, FormElement pxParent, boolean pbDataBinding)
          Create a new FormSet element.
 
Method Summary
 void clearSelected()
          Clears all currently selected values.
 Object getApplicationElement()
          Returns the application object that corresponds to this form object.
abstract  String[] getDefaultIds()
          Return the default ids.
 String getErrorCode()
          Returns the error code of the element
 String getFirstSelected()
          Return the selected ids.
abstract  Set getIds()
          Return all the ids.
 String getName()
          Returns the name of the the form element.
 String getPath()
          Returns the path to the form element.
abstract  boolean getRequired()
          Returns the required flag.
 Set getSelected()
          Return the selected ids.
 boolean isSelected(String psValue)
          Check that the set value has been selected.
 void map(org.jdom.Element pxElement)
          Maps the element into a DOM document.
 void service(HttpServletRequest pxRequest, org.jdom.Element pxOldValue)
          Process the returning HTTP request.
 void setErrorCode(String psCode)
          Sets the error code.
 void setSelected(String[] pxValues)
          Clear current list of selected ids and set new ones.
 void setSelected(String psId, boolean pbValue)
          Set the selected state of an Id.
 void setToDefault(boolean pbRecursive)
          Return value to the default settings.
 int validate(boolean pbRecursive)
          validate the element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormSet

public FormSet(String psName,
               Object pxApplicationElement,
               FormElement pxParent,
               boolean pbDataBinding)
Create a new FormSet element. When the set has runtime data binding only basic validation can take place.

Parameters:
psName - name of element
pxParent - path to the parent in the xml tree
pbDataBinding - the dataset is fully or partially derived
Method Detail

clearSelected

public void clearSelected()
Clears all currently selected values. Note that even cfs:select-ones are backed by a FormSet object so you must call this method before setting new selected values.


isSelected

public boolean isSelected(String psValue)
Check that the set value has been selected.

Parameters:
psValue - Set value to be checked
Returns:
true on selected

getSelected

public Set getSelected()
Return the selected ids.

Returns:
the selected values

getFirstSelected

public String getFirstSelected()
Return the selected ids.

Returns:
the selected values

setSelected

public void setSelected(String psId,
                        boolean pbValue)
Set the selected state of an Id.

Parameters:
psId - Id to be selected
pbValue - value, true is selected

setSelected

public void setSelected(String[] pxValues)
Clear current list of selected ids and set new ones.

Parameters:
pxValues - new selected values

getDefaultIds

public abstract String[] getDefaultIds()
Return the default ids.

Returns:
the ids

getIds

public abstract Set getIds()
Return all the ids.

Returns:
the ids

getRequired

public abstract boolean getRequired()
Returns the required flag. A true means the element requires input to be in a valid state.

Returns:
the required flag

map

public void map(org.jdom.Element pxElement)
Maps the element into a DOM document.

Specified by:
map in interface FormElement
Parameters:
pxElement - parent element to add new elements onto

getErrorCode

public String getErrorCode()
Returns the error code of the element

Specified by:
getErrorCode in interface FormElement
Returns:
error code

getName

public String getName()
Description copied from interface: FormElement
Returns the name of the the form element.

Specified by:
getName in interface FormElement
Returns:
the name
See Also:
Form

getPath

public String getPath()
Description copied from interface: FormElement
Returns the path to the form element. This path uniquely identifies the data object in the DOM tree and when the object is returned through the form.

Specified by:
getPath in interface FormElement
Returns:
the name
See Also:
FormElement

getApplicationElement

public Object getApplicationElement()
Description copied from interface: FormElement
Returns the application object that corresponds to this form object.

Specified by:
getApplicationElement in interface FormElement
See Also:
FormElement

service

public void service(HttpServletRequest pxRequest,
                    org.jdom.Element pxOldValue)
Process the returning HTTP request.

Specified by:
service in interface FormElement
Parameters:
pxRequest - http request to fetch data from
pxOldValue - form element details when the form was sent to the user

setErrorCode

public void setErrorCode(String psCode)
Description copied from interface: FormElement
Sets the error code. JSP's may do this to display an error found outside of built-in validation.

Specified by:
setErrorCode in interface FormElement
Parameters:
psCode - error code
See Also:
FormElement

setToDefault

public void setToDefault(boolean pbRecursive)
Return value to the default settings.

Specified by:
setToDefault in interface FormElement
Parameters:
pbRecursive - on true set child elements

validate

public int validate(boolean pbRecursive)
validate the element.

Specified by:
validate in interface FormElement
Parameters:
pbRecursive - on true check child elements
Returns:
error count