|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.formaria.aria.validation.ValidationHandler
public class ValidationHandler
Provides a means of managing validations. This class is intended as a mixin class for the panel classes such as Page. Validations are integrated with the event handler so that when the event with which the validation is associated is triggered the validation is invoked. Failure of a validation results in subsequent event handler methods being blocked.
Validations are also invoked at page transition and all validations rules are checked. If all validations are not passed then the page transition can be blocked.
If a validation failes then an exception is thrown. The exception is by default handled by this class but it can be redirected to a custom exception handler with the setExceptionHandler method. This interface allows exceptions to handled in a variety of different ways.
Copyright: Copyright (c) Formaria Ltd., 2008
License: see license.txt
$Revision: 2.10 $
| Field Summary | |
|---|---|
protected java.lang.Object |
container
For accessing function validations |
protected ExceptionHandler |
customExceptionHandler
The ExceptionHandler which will handle validation exceptions |
protected ValidationFactory |
validationFactory
The project ValidationFactory |
protected java.util.Hashtable |
validations
Hashtable of project validations |
| Constructor Summary | |
|---|---|
ValidationHandler(java.lang.Object c)
Create a new validation handler for the specified container. |
|
| Method Summary | |
|---|---|
int |
accumulateMessages(boolean accumulate,
int level)
informs the handler when a page validation is starting or stopping. |
Validator |
addValidation(AriaEventHandler eventHandler,
java.lang.Object comp,
java.lang.String validationName)
Adds a validation to this page. |
Validator |
addValidation(AriaEventHandler eventHandler,
java.lang.Object comp,
java.lang.String validationName,
java.lang.String method)
Adds a validation to this page. |
Validator |
addValidation(AriaEventHandler eventHandler,
java.lang.Object comp,
java.lang.String validationName,
java.lang.String method,
int mask,
XmlElement pageEle)
Adds a validation to this page. |
int |
checkValidations(java.lang.Object scope)
Check all validations for this page. |
void |
clearValidations()
Reset/removes all validations |
Validator |
getValidation(java.lang.String validationName,
java.lang.String method)
Gets a Validator object. |
Validator |
getValidation(java.lang.String validationName,
java.lang.String method,
int mask,
XmlElement pageEle)
Adds a validation to this page. |
java.util.Vector |
getValidations(java.lang.Object comp)
Gets all the validations installed for a component |
boolean |
handleEventHandlerException(Project project,
java.lang.Object container,
java.lang.Throwable error)
Handle an exception during the invocation of a page's event handler. |
boolean |
handleException(java.lang.Object comp,
java.lang.Exception ex,
java.lang.Object validator)
A method called when a validation exeption has been trapped. |
void |
removeValidations(java.lang.Object comp)
Remove any validations bound to the passed component |
void |
setExceptionHandler(ExceptionHandler eh)
Set the exception handler called when a validation exception is trapped |
void |
setupEventHandler(AriaEventHandler eh)
Set the event handler instance. |
void |
setupEventHandler(AriaEventHandler eh,
java.lang.String focusEvent,
long mask)
Set the event handler instance. |
void |
setValidationFactory(ValidationFactory vf)
Sets the factory used to create Validator objects |
int |
validationHandler(AriaEventHandler eventHandler)
Invoke the validators for the last event. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ValidationFactory validationFactory
protected java.util.Hashtable validations
protected ExceptionHandler customExceptionHandler
protected java.lang.Object container
| Constructor Detail |
|---|
public ValidationHandler(java.lang.Object c)
c - the container| Method Detail |
|---|
public void setupEventHandler(AriaEventHandler eh)
eh - the event handler
public void setupEventHandler(AriaEventHandler eh,
java.lang.String focusEvent,
long mask)
eh - the event handlerfocusEvent - the class name of the focus eventthe - event maskpublic void setExceptionHandler(ExceptionHandler eh)
eh - The ExceptionHandler to be usedpublic void clearValidations()
public Validator addValidation(AriaEventHandler eventHandler,
java.lang.Object comp,
java.lang.String validationName,
java.lang.String method,
int mask,
XmlElement pageEle)
eventHandler - the current event handler that this handler will use to
listen to for events that should trigger validationscomp - the component being validatedvalidationName - the name of the validation in the validation filemethod - the method used to get the component's value if anymask - the event mask used to filter the events that trigger the validationpageEle - the XML element which is declared in the page
public Validator getValidation(java.lang.String validationName,
java.lang.String method,
int mask,
XmlElement pageEle)
method - The Method to be called for a function validationvalidationName - the name of the validation in the validation filemask - the event mask used to filter the events that trigger the validation
public Validator getValidation(java.lang.String validationName,
java.lang.String method)
validationName - the name of the validation in the validation filemethod - the method used to get the component's value if any
public java.util.Vector getValidations(java.lang.Object comp)
comp - the target component
public void removeValidations(java.lang.Object comp)
comp - The component being validated
public Validator addValidation(AriaEventHandler eventHandler,
java.lang.Object comp,
java.lang.String validationName,
java.lang.String method)
eventHandler - the current event handler that this handler will use to
listen to for events that should trigger validationscomp - the component being validatedvalidationName - the name of the validation in the validation filemethod - the method used to get the component's value if any
public Validator addValidation(AriaEventHandler eventHandler,
java.lang.Object comp,
java.lang.String validationName)
eventHandler - the current event handler that this handler will use to
listen to for events that should trigger validationscomp - the component being validatedvalidationName - the name of the validation in the validation file
public void setValidationFactory(ValidationFactory vf)
vf - The ValidationFactory to be usedpublic int validationHandler(AriaEventHandler eventHandler)
the - event handler
public int checkValidations(java.lang.Object scope)
public int accumulateMessages(boolean accumulate,
int level)
accumulateMessages in interface ExceptionHandlerlevel - The worst level of validation resulting from prior validationsaccumulate - boolean to indicate whether the accumulation is started or stopped.
public boolean handleException(java.lang.Object comp,
java.lang.Exception ex,
java.lang.Object validator)
handleException in interface ExceptionHandlercomp - Component being validatedex - The exception causedvalidator - The validator being used to validate.
public boolean handleEventHandlerException(Project project,
java.lang.Object container,
java.lang.Throwable error)
handleEventHandlerException in interface ExceptionHandlerproject - the current projectcontainer - the pageerror - the exception or error that was thrown
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||