Registering a Custom Validator
Registering a Custom Validator
To access the localized message, the page author uses a value expression to reference the key of
the message from the resource bundle. See
for more
information.
Registering a Custom Validator
If the application developer provides an implementation of the Validator interface to perform
validation, you must register this custom validator in the application configuration resource file
by using the validator XML element:
<validator>
...
<validator-id>FormatValidator</validator-id>
<validator-class>
com.sun.bookstore6.validators.FormatValidator
</validator-class>
<attribute>
...
<attribute-name>formatPatterns</attribute-name>
<attribute-class>java.lang.String</attribute-class>
</attribute>
</validator>
The validator-id and validator-class elements are required subelements. The
validator-id
element represents the identifier under which the Validator class should be
registered. This ID is used by the tag class corresponding to the custom validator tag.
The validator-class element represents the fully qualified class name of the Validator class.
The attribute element identifies an attribute associated with the Validator implementation.
It has required attribute-name and attribute-class subelements. The attribute-name
element refers to the name of the attribute as it appears in the validator tag. The
attribute-class
element identifies the Java type of the value associated with the attribute.
explains how to implement the Validator
interface.
explains how to reference the validator from the page.
Registering a Custom Validator
The Java EE 5 Tutorial · September 2007
450