|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.xoetrope.xui.validation.XValidationHandler
public class XValidationHandler
Provides a means of managing validations. This class is intended as a mixin class for the panel classes such as XPage. 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) Xoetrope Ltd., 1998-2003
License: see license.txt $Revision: 2.10 $
Field Summary | |
---|---|
protected java.lang.Object |
container For accessing function validations |
protected XExceptionHandler |
customExceptionHandler The XExceptionHandler which will handle validation exceptions |
protected XValidationFactory |
validationFactory The project XValidationFactory |
protected java.util.Hashtable |
validations Hashtable of project validations |
Constructor Summary | |
---|---|
XValidationHandler(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. |
XValidator |
addValidation(XuiEventHandler eventHandler, java.lang.Object comp, java.lang.String validationName) Adds a validation to this page. |
XValidator |
addValidation(XuiEventHandler eventHandler, java.lang.Object comp, java.lang.String validationName, java.lang.String method) Adds a validation to this page. |
XValidator |
addValidation(XuiEventHandler 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() Check all validations for this page. |
void |
clearValidations() Reset/removes all validations |
XValidator |
getValidation(java.lang.String validationName, java.lang.String method) Gets a XValidator object. |
XValidator |
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(XProject 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(XExceptionHandler eh) Set the exception handler called when a validation exception is trapped |
void |
setupEventHandler(XuiEventHandler eh) Set the event handler instance. |
void |
setValidationFactory(XValidationFactory vf) Sets the factory used to create XValidator objects |
int |
validationHandler(XuiEventHandler 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 XValidationFactory validationFactory
protected java.util.Hashtable validations
protected XExceptionHandler customExceptionHandler
protected java.lang.Object container
Constructor Detail |
---|
public XValidationHandler(java.lang.Object c)
c
- the containerMethod Detail |
---|
public void setupEventHandler(XuiEventHandler eh)
eh
- the event handlerpublic void setExceptionHandler(XExceptionHandler eh)
eh
- The ExceptionHandler to be usedpublic void clearValidations()
public XValidator addValidation(XuiEventHandler 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 pagepublic XValidator 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 validationpublic XValidator 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 anypublic java.util.Vector getValidations(java.lang.Object comp)
comp
- the target componentpublic void removeValidations(java.lang.Object comp)
comp
- The component being validatedpublic XValidator addValidation(XuiEventHandler 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 anypublic XValidator addValidation(XuiEventHandler 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 filepublic void setValidationFactory(XValidationFactory vf)
vf
- The ValidationFactory to be usedpublic int validationHandler(XuiEventHandler eventHandler)
the
- event handlerpublic int checkValidations()
public int accumulateMessages(boolean accumulate, int level)
accumulateMessages
in interface XExceptionHandler
level
- 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 XExceptionHandler
comp
- Component being validatedex
- The exception causedvalidator
- The validator being used to validate.public boolean handleEventHandlerException(XProject project, java.lang.Object container, java.lang.Throwable error)
handleEventHandlerException
in interface XExceptionHandler
project
- 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 |