Download
FAQ History |
API
Search Feedback |
Registering a Custom Validator
Just as the message resources must be made available at application startup time, so does the custom validator. If the application developer provides an implementation of the
Validator
interface to perform the validation, you must register this custom validator in the application configuration resource file by using thevalidator
XML element:<validator> ... <validator-id>FormatValidator</validator-id> <validator-class>validators.FormatValidator</validator- class> <attribute> ... <attribute-name>formatPatterns</attribute-name> <attribute-class>java.lang.String</attribute-class> </attribute> </validator>The
validator-id
andvalidator-class
elements are required subelements. Thevalidator-id
represents the identifier under which theValidator
class should be registered. This ID is used by the tag class corresponding to the customvalidator
tag.The
validator-class
element represents the fully qualified class name of theValidator
class.The
attribute
element identifies an attribute associated with theValidator
. It has requiredattribute-name
andattribute-class
subelements. Theattribute-name
element refers to the name of the attribute as it appears in thevalidator
tag. Theattribute-class
element identifies the Java type of the value associated with the attribute.Creating a Custom Validator explains how to implement the
Validator
interface.Using a Custom Validator explains how to reference the validator from the page.
Download
FAQ History |
API
Search Feedback |
All of the material in The J2EE(TM) 1.4 Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.