The Java EE 5 Tutorial

Referencing Localized Static Data

To reference static localized data from a resource bundle, you use a value expression from an attribute of the component tag that will display the localized data. You can reference the message from any component tag attribute that is enabled to accept value expressions.

The value expression has the notation var.message, in which var matches the var attribute of the loadBundle tag or the var element in the configuration file, and message matches the key of the message contained in the resource bundle, referred to by the var attribute. Here is an example from bookstore.jsp:

<h:outputText value="#{bundle.Talk}"/>

Notice that bundle matches the var attribute from the loadBundle tag and that Talk matches the key in the ResourceBundle.

Another example is the graphicImage tag from chooselocale.jsp:

<h:graphicImage id="mapImage" url="/template/world.jpg"
    usemap="#worldMap" />

The alt attribute is enabled to accept value expressions. In this case, the alt attribute refers to localized text that will be included in the alternative text of the image rendered by this tag.

See Creating Custom Component Classes and Enabling Component Properties to Accept Expressions for information on how to enable value binding on your custom component’s attributes.