toolbox.web.validation
Class FormField

Package class diagram package FormField
java.lang.Object
  extended by toolbox.web.validation.FormField

public class FormField
extends java.lang.Object

Class describing a single form field.


Constructor Summary
FormField(java.lang.String name, java.lang.String display, java.lang.String type, java.lang.String req, java.lang.String format, java.lang.String defVal)
          Create a new FormField instance.
 
Method Summary
 java.lang.Object getDefault()
          Returns the default value for this field.
 java.lang.String getDisplay()
          Returns the display name of this field.
 boolean isRequired()
          Indicates whether or not this field is required.
 java.lang.Object validate(java.lang.String value)
          Validate the given String value and return an instance of the configured target type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormField

public FormField(java.lang.String name,
                 java.lang.String display,
                 java.lang.String type,
                 java.lang.String req,
                 java.lang.String format,
                 java.lang.String defVal)
          throws ValidationException
Create a new FormField instance.

In addition to setting up the simple members, a Constructor instance for the configured Java type of this field is also created. The constructor will be used to construct instances of the configured type.

Parameters:
name - Name of this field.
display - Display name for this field.
type - Java type of this field.
req - String containing "true" or "false" to inidicate whether this field is required or not.
format - If this field is of type "java.util.Date" use this format to parse Date instances.
defVal - Default value for this field.
Throws:
ValidationException - if this field cannot be created.
Method Detail

validate

public java.lang.Object validate(java.lang.String value)
                          throws ValidationException
Validate the given String value and return an instance of the configured target type.

Parameters:
value - String value to validate.
Returns:
Object containing target type value.
Throws:
ValidationException - if the value could not be validated.

getDefault

public java.lang.Object getDefault()
Returns the default value for this field. Null if no value is configured.

Returns:
Object containing default value.

getDisplay

public java.lang.String getDisplay()
Returns the display name of this field.

Returns:
String containing the display name for this field.

isRequired

public boolean isRequired()
Indicates whether or not this field is required.

Returns:
boolean indicating whether or not this field is required.