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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

...<br />

newsletters<br />

<br />

java.util.ArrayList<br />

<br />

application<br />

<br />

javax.faces.model.SelectItem<br />

#{newsletter0}<br />

#{newsletter1}<br />

#{newsletter2}<br />

#{newsletter3}<br />

<br />

<br />

<br />

newsletter0<br />

<br />

javax.faces.model.SelectItem<br />

<br />

none<br />

<br />

label<br />

Duke’s Quarterly<br />

<br />

<br />

value<br />

200<br />

<br />

<br />

...<br />

This configuration initializes a List called newsletters. This list is composed of SelectItem<br />

instances, which are also managed beans. See “Using the selectItem Tag” on page 347 for<br />

more information on SelectItem. Note that, unlike the example in “Initializing Map<br />

Properties” on page 441, the newsletters list is not a property on a managed bean. (It is not<br />

wrapped with a managed-property element.) Instead, the list is the managed bean.<br />

Registering Custom Error Messages<br />

Registering Custom Error Messages<br />

If you create custom error messages (which are displayed by the message and messages tags) for<br />

your custom converters or validators, you must make them available at application startup<br />

time. You do this in one of two ways: by queuing the message onto the FacesContext instance<br />

programmatically (as described in “Performing Localization” on page 388) or by registering the<br />

messages with your application using the application configuration resource file.<br />

Here is the part of the file that registers the messages for the Duke’s Bookstore application:<br />

Chapter 14 • Configuring <strong>Java</strong>Server Faces Applications 445

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

Saved successfully!

Ooh no, something went wrong!