A JavaServer Faces page uses the message or messages tags to access error messages, as explained in Displaying Error Messages with the message and messages Tags.
The error messages that these tags access include:
The standard error messages that accompany the standard converters and validators that ship with the API. See section 2.5.4 of the JavaServer Faces specification, version 1.2, for a complete list of standard error messages.
Custom error messages contained in resource bundles registered with the application by the application architect using the message-bundle element in the configuration file.
Custom error messages hard coded in custom converter and validator classes.
When a converter or validator is registered on an input component, the appropriate error message is automatically queued on the component.
A page author can override the error messages queued on a component by using the following attributes of the component’s tag:
converterMessage: References the error message to display when the data on the enclosing component can not be converted by the converter registered on this component.
requiredMessage: References the error message to display when no value has been entered into the enclosing component.
validatorMessage: References the error message to display when the data on the enclosing component cannot be validated by the validator registered on this component.
All three attributes are enabled to take literal values and value expressions. If an attribute uses a value expression, this expression references the error message in a resource bundle. This resource bundle must be made available to the application in one of the following ways:
By the page author using the loadBundle tag
By the application architect using the resource-bundle element in the configuration file
Conversely, the message-bundle element must be used to make available to the application those resource bundles containing custom error messages that are queued on the component as a result of a custom converter or validator being registered on the component.
The bookcashier.jsp page includes an example of the requiredMessage attribute using a value expression to reference an error message:
<h:inputText id="ccno" size="19" required="true" requiredMessage="#{customMessages.ReqMessage}" > ... </h:inputText> <h:message styleClass="error-message" for="ccno"/>
The value expression that requiredMessage is using 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 display wherever the message or messages tag is placed on the page.
See Registering Custom Error Messages and Registering Custom Localized Static Text for information on how to use the message-bundle and resource-bundle element to register resource bundles that contain error messages.