background image

Registering Custom Localized Static Text

<< Registering Custom Error Messages | Registering a Custom Validator >>
<< Registering Custom Error Messages | Registering a Custom Validator >>

Registering Custom Localized Static Text

The supported-locale and default-locale tags accept the lowercase, two-character codes as
defined by ISO 639 (see
http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt
).
Make sure that your resource bundle actually contains the messages for the locales that you
specify with these tags.
To access the localized message, the application developer merely references the key of the
message from the resource bundle. See
"Performing Localization" on page 390
for more
information.
Registering Custom Localized Static Text
Any custom localized static text you create that is not loaded into the page using the
loadBundle
tag must be registered with the application using the resource-bundle element in
the application configuration resource file for your pages to have access to the text. Likewise,
any custom error messages that are referenced by the converterMessage, requiredMessage, or
validatorMessage
attributes of an input component tag must also be made available to the
application by way of the loadBundle tag or the resource-bundle element of the application
configuration file.
Here is the part of the file that registers some custom error messages for the Duke's Bookstore
application:
<application>
...
<resource-bundle>
<base-name>
com.sun.bookstore6.resources.CustomMessages
</base-name>
<var>customMessages</var>
</resource-bundle>
...
</application>
Similarly to the loadBundle tag, the value of the base-name subelement specifies the
fully-qualified class name of the ResourceBundle class, which in this case is located in the
resources
package of the application.
Also similarly to the var attribute of the loadBundle tag, the var subelement of the
resource-bundle
element is an alias to the ResourceBundle class. This alias is used by tags in
the page to identify the resource bundle.
The locale-config element shown in the previous section also applies to the messages and
static text identified by the resource-bundle element. As with resource bundles identified by
the message-bundle element, make sure that the resource bundle identified by the
resource-bundle
element actually contains the messages for the locales that you specify with
these locale-config elements.
Registering Custom Localized Static Text
Chapter 14 · Configuring JavaServer Faces Applications
449