|
||||||||||
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,
String name,
String errorMessage)
Creates a new validator and adds it to the specified form. |
Method Summary | |
---|---|
String |
getErrorMessage()
|
String |
getName()
|
void |
setErrorMessage(String message)
Sets the error message for this validator -- useful when the error message need to be changed dynamically. |
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, String name, 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 String getErrorMessage()
public void setErrorMessage(String message)
public String getName()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |