10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Using Localized Data<br />

350<br />

referencing the error messages from the input component attributes described in “Referencing<br />

Error Messages” on page 350. In that case, you load the resource bundles containing these<br />

messages in the same way you load resource bundles containing static text.<br />

Referencing Localized Static Data<br />

To reference static localized data from a resource bundle, you use a value expression from an<br />

attribute of the component tag that will display the localized data. You can reference the<br />

message from any component tag attribute that is enabled to accept value expressions.<br />

<strong>The</strong> value expression has the notation var.message, in which var matches the var attribute of<br />

the loadBundle tag or the var element in the configuration file, and message matches the key of<br />

the message contained in the resource bundle, referred to by the var attribute. Here is an<br />

example from bookstore.jsp:<br />

<br />

Notice that bundle matches the var attribute from the loadBundle tag and that Talk matches<br />

the key in the ResourceBundle.<br />

Another example is the graphicImage tag from chooselocale.jsp:<br />

<br />

<strong>The</strong> alt attribute is enabled to accept value expressions. In this case, the alt attribute refers to<br />

localized text that will be included in the alternative text of the image rendered by this tag.<br />

See “Creating Custom Component Classes” on page 417 and “Enabling Component Properties<br />

to Accept Expressions” on page 422 for information on how to enable value binding on your<br />

custom component’s attributes.<br />

Referencing Error Messages<br />

A <strong>Java</strong>Server Faces page uses the message or messages tags to access error messages, as<br />

explained in “Displaying Error Messages with the message and messages Tags” on page 347.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!