org.araneaframework.uilib.form.constraint
Class BaseFieldConstraint

java.lang.Object
  extended by org.araneaframework.uilib.form.constraint.BaseConstraint
      extended by org.araneaframework.uilib.form.constraint.BaseFieldConstraint
All Implemented Interfaces:
Serializable, Constraint
Direct Known Subclasses:
AfterTodayConstraint, NotEmptyConstraint, NumberInRangeConstraint, OptionalConstraint, StringLengthInRangeConstraint

public abstract class BaseFieldConstraint
extends BaseConstraint

Base implementation of the Constraint that is associated with some FormElement. Most constraints may find it useful to extend this form-field-related implementation to define a new constraint.

Author:
Taimo Peelo (taimo@araneaframework.org)
See Also:
Serialized Form

Nested Class Summary
static class BaseFieldConstraint.FieldConstraintException
          Exception thrown when FormElement associated with BaseFieldConstraint could not be determined.
 
Field Summary
 
Fields inherited from class org.araneaframework.uilib.form.constraint.BaseConstraint
customErrorMessage
 
Constructor Summary
BaseFieldConstraint()
          An empty constructor that does not bind this constraint with a form element.
BaseFieldConstraint(FormElement field)
          A constructor that binds this constraint with given form element (field)
 
Method Summary
 Environment getEnvironment()
          Provides the Environment of the constraint.
protected  FormElementContext getField()
          Returns the FormElement that this Constraint is constraining.
protected  String getLabel()
          Provides the label of the constraint field.
protected  Object getValue()
          Provides the value of the constraint field.
 boolean isDisabled()
          Specifies whether the constraint field is disabled.
 boolean isMandatory()
          Specifies whether the constraint field is mandatory.
 boolean isRead()
          Specifies whether the constraint field was read.
 
Methods inherited from class org.araneaframework.uilib.form.constraint.BaseConstraint
addError, addErrors, clearErrors, getConfiguration, getErrors, isValid, setCustomErrorMessage, setEnvironment, t, validate, validateConstraint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseFieldConstraint

public BaseFieldConstraint()
An empty constructor that does not bind this constraint with a form element. The only way to bind a constraint with a form field, is by a constructor.)


BaseFieldConstraint

public BaseFieldConstraint(FormElement field)
A constructor that binds this constraint with given form element (field)

Parameters:
field - The form element to bind this contraint with.
Method Detail

getField

protected FormElementContext getField()
Returns the FormElement that this Constraint is constraining.

Returns:
constrained FormElement

getEnvironment

public Environment getEnvironment()
Description copied from class: BaseConstraint
Provides the Environment of the constraint.

Overrides:
getEnvironment in class BaseConstraint
Returns:
the Environment of the constraint.

getLabel

protected String getLabel()
Provides the label of the constraint field.

Returns:
the label of the constraint field.

getValue

protected Object getValue()
Provides the value of the constraint field.

Returns:
the value of the constraint field.

isRead

public boolean isRead()
Specifies whether the constraint field was read.

Returns:
a Boolean indicating whether the constraint field was read.

isDisabled

public boolean isDisabled()
Specifies whether the constraint field is disabled.

Returns:
a Boolean indicating whether the constraint field is disabled.

isMandatory

public boolean isMandatory()
Specifies whether the constraint field is mandatory.

Returns:
a Boolean indicating whether the constraint field is mandatory.