The Java EE 5 Tutorial

Loading a Resource Bundle

To reference error messages or static data from the page, you first need to make available the resource bundle containing the data.

To make available resource bundles that contain static data, you need to do one of two things:

Here is an example loadBundle tag from bookstore.jsp:

<f:loadBundle var="bundle"
    basename="messages.BookstoreMessages" />

The basename attribute value specifies the fully-qualified class name of the ResourceBundle class, which in this case is located in the messages package of the bookstore application.

The var attribute is an alias to the ResourceBundle class. This alias can be used by other tags in the page in order to access the localized messages.

In the case of resource bundles that contain error messages, you need to register the resource bundle with the application in the configuration file using the message-bundle element, as explained in Registering Custom Error Messages. One exception is if you are referencing the error messages from the input component attributes described in Referencing Error Messages. In that case, you load the resource bundles containing these messages in the same way you load resource bundles containing static text.