org.apache.commons.validator

Class Form

public class Form extends Object implements Serializable

This contains a set of validation rules for a form/JavaBean. The information is contained in a list of Field objects. Instances of this class are configured with a <form> xml element.

The use of FastHashMap is deprecated and will be replaced in a future release.

Field Summary
protected FastHashMaphFields
Map of Fields keyed on their property value.
protected ListlFields
List of Fields.
protected Stringname
The name/key the set of validation rules is stored under.
Method Summary
voidaddField(Field f)
Add a Field to the Form.
booleancontainsField(String fieldName)
Returns true if this Form contains a Field with the given name.
FieldgetField(String fieldName)
Returns the Field with the given name or null if this Form has no such field.
MapgetFieldMap()
The Fields are returned as an unmodifiable Map.
ListgetFields()
A List of Fields is returned as an unmodifiable List.
StringgetName()
Gets the name/key of the set of validation rules.
voidprocess(Map globalConstants, Map constants)
Processes all of the Form's Fields.
voidsetName(String name)
Sets the name/key of the set of validation rules.
StringtoString()
Returns a string representation of the object.
ValidatorResultsvalidate(Map params, Map actions, int page)
Validate all Fields in this Form on the given page and below.

Field Detail

hFields

protected FastHashMap hFields
Map of Fields keyed on their property value.

lFields

protected List lFields
List of Fields. Used to maintain the order they were added in although individual Fields can be retrieved using Map of Fields.

name

protected String name
The name/key the set of validation rules is stored under.

Method Detail

addField

public void addField(Field f)
Add a Field to the Form.

containsField

public boolean containsField(String fieldName)
Returns true if this Form contains a Field with the given name.

Since: Validator 1.1

getField

public Field getField(String fieldName)
Returns the Field with the given name or null if this Form has no such field.

Since: Validator 1.1

getFieldMap

public Map getFieldMap()

Deprecated: Use containsField(String) and getField(String) instead.

The Fields are returned as an unmodifiable Map.

getFields

public List getFields()
A List of Fields is returned as an unmodifiable List.

getName

public String getName()
Gets the name/key of the set of validation rules.

process

public void process(Map globalConstants, Map constants)

Deprecated: This method is called by the framework. It will be made protected in a future release. TODO

Processes all of the Form's Fields.

setName

public void setName(String name)
Sets the name/key of the set of validation rules.

toString

public String toString()
Returns a string representation of the object.

validate

ValidatorResults validate(Map params, Map actions, int page)
Validate all Fields in this Form on the given page and below.

Parameters: params A Map of parameter class names to parameter values to pass into validation methods. actions A Map of validator names to ValidatorAction objects. page Fields on pages higher than this will not be validated.

Returns: A ValidatorResults object containing all validation messages.

Throws: ValidatorException

Copyright (c) 2001-2004 Apache Software Foundation