|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A FormValidator is designed to validate one or more FormElements within a FormMap, OR a FormMap itself. The real work occurs in the validate() method.
When the validate method is invoked, we start by performing element level validation by invoking the validateFormElement() methods for each of the elements in the form. If that succeeds, we validate the whole map by invoking validateForm() method to validate the form itself. Finally, we invoke any child validators. In this way, a validator is not considered validated until all it's rules plus those for all of it's children have passed muster.
When an invalid condition occurs, typically the developer will throw a ValidationException, which stops the validation process immediately and returns the specified error. There are times, however, where the developer will want to try and validate as many of the rules as possible in order to return all known errors at once. In this case, the developer should throw DeferredValidationExceptions. These are caught internally and added to one master validation exception, which is thrown when the validation process completes.
Method Summary | |
java.lang.String |
getErrorMessage()
Get the error message to be used in the event of an error. |
boolean |
isNull(java.lang.Object val,
FormElement element)
Check if val passed is null in a consistant manner. |
void |
setErrorMessage(java.lang.String ierrorMessage)
Set the error message to be used in the event of an error. |
void |
validate(FormElement element,
FormMap formMap,
boolean deferExceptions)
Validate a FormElement locally and allow any child validators a chance to validate as well. |
Method Detail |
public void setErrorMessage(java.lang.String ierrorMessage)
public java.lang.String getErrorMessage()
public void validate(FormElement element, FormMap formMap, boolean deferExceptions) throws ValidationException
element
- the form element to be validated (null indicates
we want to perform form level validation)deferExceptions
- do we want to deferValidation exceptions
and attempt to validate all elements so that we can process
all the exceptions at once
ValidationException
- if the element is not validpublic boolean isNull(java.lang.Object val, FormElement element)
val
- the value to test for nullness
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |