org.formproc.form
Class AbstractFormElement

java.lang.Object
  |
  +--org.formproc.form.AbstractFormElement
All Implemented Interfaces:
FormElement
Direct Known Subclasses:
BasicFormElement, DefaultFormElement

public abstract class AbstractFormElement
extends java.lang.Object
implements FormElement

An abstract base class which implements the FormElement interface.

Author:
Anthony Eden

Field Summary
protected  java.lang.String defaultValue
           
protected  FormElementGroup formElementGroup
           
protected  MessageProvider messageProvider
           
protected  java.util.HashMap messages
           
protected  java.lang.String name
           
protected  boolean optional
           
protected  Storer storer
           
protected  TypeConverter typeConverter
           
protected  Validator validator
           
protected  java.lang.String writeMethod
           
 
Constructor Summary
AbstractFormElement()
          Default constructor.
AbstractFormElement(FormElementGroup formElementGroup)
          Construct a new AbstractFormElement which is member of the given FormElementGroup.
 
Method Summary
 java.lang.String getDefaultValue()
          Get the default value which is used if no data is submitted for the given form element.
 java.lang.String getMessage()
          Get the field's message in the default Locale.
 java.lang.String getMessage(java.util.Locale locale)
          Get the message in the given Locale.
 java.lang.String getName()
          Get the FormElement name.
 Storer getStorer()
          Get the Storer used to store field data in the target object.
 TypeConverter getTypeConverter()
          Get the TypeConverter which will be applied before invoking the target object's write method.
 Validator getValidator()
          Get the validator for this field.
 java.lang.String getWriteMethod()
          Get a predefined write method for the given form element.
 boolean isOptional()
          Return true if the FormElement is optional.
 void setDefaultValue(java.lang.String defaultValue)
          Set the default value which is used if no data is submitted for the given form element.
 void setName(java.lang.String name)
          Set the FormElement name.
 void setOptional(boolean optional)
          Set to true if the FormElement is optional.
 void setOptional(java.lang.String optional)
          Set to "true" if the FormElement is optional.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

formElementGroup

protected FormElementGroup formElementGroup

messages

protected java.util.HashMap messages

writeMethod

protected java.lang.String writeMethod

name

protected java.lang.String name

defaultValue

protected java.lang.String defaultValue

optional

protected boolean optional

validator

protected Validator validator

typeConverter

protected TypeConverter typeConverter

storer

protected Storer storer

messageProvider

protected MessageProvider messageProvider
Constructor Detail

AbstractFormElement

public AbstractFormElement()
Default constructor.


AbstractFormElement

public AbstractFormElement(FormElementGroup formElementGroup)
Construct a new AbstractFormElement which is member of the given FormElementGroup.

Parameters:
formElementGroup - The formElementGroup
Method Detail

getName

public java.lang.String getName()
Get the FormElement name.

Specified by:
getName in interface FormElement
Returns:
The name

setName

public void setName(java.lang.String name)
Set the FormElement name.

Parameters:
name - The name

getDefaultValue

public java.lang.String getDefaultValue()
Get the default value which is used if no data is submitted for the given form element. This method may return if no default value is specified.

Specified by:
getDefaultValue in interface FormElement
Returns:
The default value or null

setDefaultValue

public void setDefaultValue(java.lang.String defaultValue)
Set the default value which is used if no data is submitted for the given form element. Set the value to null if no default value should be used.

Specified by:
setDefaultValue in interface FormElement
Parameters:
defaultValue - The new default value

isOptional

public boolean isOptional()
Return true if the FormElement is optional. Optional form elements can have an empty value.

Specified by:
isOptional in interface FormElement
Returns:
True if the element is optional

setOptional

public void setOptional(boolean optional)
Set to true if the FormElement is optional.

Specified by:
setOptional in interface FormElement
Parameters:
optional - True if the element is optional

setOptional

public void setOptional(java.lang.String optional)
Set to "true" if the FormElement is optional.

Specified by:
setOptional in interface FormElement
Parameters:
optional - String "true" if element is optional

getMessage

public java.lang.String getMessage()
Get the field's message in the default Locale.

Specified by:
getMessage in interface FormElement
Returns:
The message

getMessage

public java.lang.String getMessage(java.util.Locale locale)
Get the message in the given Locale.

Specified by:
getMessage in interface FormElement
Parameters:
locale - The Locale
Returns:
The message

getWriteMethod

public java.lang.String getWriteMethod()
Get a predefined write method for the given form element. If the write method is not defined then this method returns null.

Specified by:
getWriteMethod in interface FormElement
Returns:
The write method

getValidator

public Validator getValidator()
Get the validator for this field. This method may return null if no Validator is specified for this FormElement.

Specified by:
getValidator in interface FormElement
Returns:
The Validator or null

getTypeConverter

public TypeConverter getTypeConverter()
Get the TypeConverter which will be applied before invoking the target object's write method. This method may return null if no TypeConverter is specified for this FormElement.

Specified by:
getTypeConverter in interface FormElement
Returns:
The TypeConverter or null

getStorer

public Storer getStorer()
Get the Storer used to store field data in the target object. This method may returbn null if no storer is specified for this FormElement.

Specified by:
getStorer in interface FormElement
Returns:
The Storer or null


Copyright (c) 2001-2003 Anthony Eden. All Rights Reserved.