|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfc.web.forms.FormValidator
public abstract class FormValidator
Represents a form level validator that may examine more than
one form field for a grouped/form level validation. Form level
validators differ from FieldValidator because one may
need to validate a group of fields together.
Examples include address validation where street, city and zip might
need to be verified together (for a valid address) or password
validation where two separate password boxes might need to be
validated (to be identical). Various subclasses implement
concrete code (via validate(fc.web.forms.FormData, javax.servlet.http.HttpServletRequest)) for various validation
strategies.
Note 1: Validator objects have state and a particular instance of a validator should only be assigned to one form field.
Thread safety: None of the validation classes (like all other form-related classes) are thread safe. Synchronization must be done at a higher level, typically the session level.
| Constructor Summary | |
|---|---|
FormValidator(Form f,
java.lang.String name,
java.lang.String errorMessage)
Creates a new validator and adds it to the specified form. |
|
| Method Summary | |
|---|---|
java.lang.String |
getErrorMessage()
|
java.lang.String |
getName()
|
void |
setErrorMessage(java.lang.String message)
Sets the error message for this validator -- useful when the error message need to be changed dynamically. |
java.lang.String |
toString()
|
abstract boolean |
validate(FormData fd,
javax.servlet.http.HttpServletRequest req)
Validates multiple fields together. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public FormValidator(Form f,
java.lang.String name,
java.lang.String errorMessage)
errorMessage - the error message associated with invalid data
See getErrorMessage()| Method Detail |
|---|
public abstract boolean validate(FormData fd,
javax.servlet.http.HttpServletRequest req)
Important notes: Typically, validation should be skipped in the following circumstances:
DependentField and the
DependentField#shouldValidate method returns false.
public java.lang.String getErrorMessage()
public void setErrorMessage(java.lang.String message)
public java.lang.String getName()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||