background image

Configuring Error Messages

<< Defining Page Navigations | Developing the Beans >>
<< Defining Page Navigations | Developing the Beans >>

Configuring Error Messages

In the case of the Guess Number example, the logical outcome is defined by the action attribute
of the UICommand component that submits the form:
<h:commandButton id=
"submit" action="success"
value=
"Submit" />
To learn more about how navigation works, see
"Navigation Model" on page 307
.
Configuring Error Messages
In case the standard error messages don't meet your needs, you can create new ones in resource
bundles and configure the resource bundles in your application configuration resource file. The
guessNumber
example has one custom converter message, as described in
"Adding a Custom
Message" on page 294
.
This message is stored in the resource bundle, ApplicationMessages.properties:
userNoConvert=The value you entered is not a number.
The resource bundle is configured in the application configuration file:
<application>
<resource-bundle>
<base-name>guessNumber.ApplicationMessages</base-name>
<var>ErrMsg</var>
</resource-bundle>
</application>
The base-name element indicates the fully-qualified name of the resource bundle. The var
element indicates the name by which page authors refer to the resource bundle with the
expression language. Here is the inputText tag again:
<h:inputText id=
"userNo" label="User Number"
value=
"#{UserNumberBean.userNumber}"
converterMessage=
"#{ErrMsg.userNoConvert}">
...
</h:inputText>
The expression on the converterMessage attribute references the userNoConvert key of the
ErrMsg
resource bundle.
See
"Registering Custom Error Messages" on page 448
for more information on configuring
custom error messages.
A Simple JavaServer Faces Application
Chapter 10 · JavaServer Faces Technology
297