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.

Adding UI Components to a Page Using the HTML ComponentTags<br />

346<br />

<strong>The</strong> value attribute of the selectItems tag is bound to the newsletters managed bean, which<br />

is configured in the application configuration resource file. <strong>The</strong> newsletters managed bean is<br />

configured as a list:<br />

<br />

newsletters<br />

<br />

java.util.ArrayList<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 />

none<br />

<br />

label<br />

Duke’s Quarterly<br />

<br />

<br />

value<br />

200<br />

<br />

<br />

...<br />

As shown in the managed-bean element, the UISelectItems component is a collection of<br />

SelectItem instances. See “Initializing Array and List Properties” on page 442 for more<br />

information on configuring collections as beans.<br />

You can also create the list corresponding to a UISelectMany or UISelectOne component<br />

programmatically in the backing bean. See “Writing Bean Properties” on page 377 for<br />

information on how to write a backing bean property corresponding to a UISelectMany or<br />

UISelectOne component.<br />

<strong>The</strong> arguments to the SelectItem constructor are:<br />

■ An Object representing the value of the item<br />

■ A String representing the label that displays in the UISelectMany component on the page<br />

■ A String representing the description of the item<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!