Java Reference
In-Depth Information
The value expression used by requiredMessage in this example references the error
message with the ReqMessage key in the resource bundle, customMessages .
This message replaces the corresponding message queued on the component and will dis-
play wherever the message or messages tag is placed on the page.
Using Default Validators
In addition to the validators you declare on the components, you can also specify zero or
more default validators in the application configuration resource file. The default validator
applies to all javax.faces.component.UIInput instances in a view or compon-
ent tree and is appended after the local defined validators. Here is an example of a default
validator registered in the application configuration resource file:
Click here to view code image
<faces-config>
<application>
<default-validators>
<validator-id>javax.faces.Bean</validator-id>
</default-validators>
<application/>
</faces-config>
Registering a Custom Validator
If the application developer provides an implementation of the
javax.faces.validator.Validator interface to perform validation, you must
register this custom validator either by using the @FacesValidator annotation, as de-
scribed in “ Implementing the Validator Interface on page 129 , or by using the valid-
ator XML element in the application configuration resource file:
Click here to view code image
<validator>
...
<validator-id>FormatValidator</validator-id>
<validator-class>
myapplication.validators.FormatValidator
</validator-class>
<attribute>
...
<attribute-name>formatPatterns</attribute-name>
<attribute-class>java.lang.String</attribute-class>
Search WWH ::




Custom Search