Registering a Custom Validator
If the application developer provides an implementation of the
Validatorinterface to perform the validation, you must register this custom validator in the application configuration resource file by using thevalidatorXML 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-idandvalidator-classelements are required subelements. Thevalidator-idelement represents the identifier under which theValidatorclass should be registered. This ID is used by the tag class corresponding to the customvalidatortag.The
validator-classelement represents the fully qualified class name of theValidatorclass.The
attributeelement identifies an attribute associated with theValidatorimplementation. It has requiredattribute-nameandattribute-classsubelements. Theattribute-nameelement refers to the name of the attribute as it appears in thevalidatortag. Theattribute-classelement identifies the Java type of the value associated with the attribute.Creating a Custom Validator explains how to implement the
Validatorinterface.Using a Custom Validator explains how to reference the validator from the page.