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.

public String getShippingOption() {<br />

return this.shippingOption;<br />

}<br />

Note that shippingOption represents the currently selected item from the list of items in the<br />

UISelectOne component.<br />

As explained in the section “Displaying a Menu Using the selectOneMenu Tag” on page 342, the<br />

UISelectItem and UISelectItems components are used to represent all the values in a<br />

UISelectOne component. See “UISelectItem Properties” on page 383 and “UISelectItems<br />

Properties” on page 383 for information on how to write the backing bean properties for the<br />

UISelectItem and UISelectItems components.<br />

UISelectItem Properties<br />

A UISelectItem component represents one value in a set of values in a UISelectMany or<br />

UISelectOne component. <strong>The</strong> backing bean property that a UISelectItem component is<br />

bound to must be of type SelectItem.ASelectItem object is composed of an Object<br />

representing the value, along with two Strings representing the label and description of the<br />

SelectItem object.<br />

<strong>The</strong> Duke’s Bookstore application does not use any UISelectItem components whose values<br />

are bound to backing beans. <strong>The</strong> example selectOneMenu tag from “Displaying a Menu Using<br />

the selectOneMenu Tag” on page 342 contains selectItem tags that set the values of the list of<br />

items in the page. Here is an example bean property that can set the values for this list in the<br />

bean:<br />

SelectItem itemOne = null;<br />

SelectItem getItemOne(){<br />

return itemOne;<br />

}<br />

void setItemOne(SelectItem item) {<br />

itemOne = item;<br />

}<br />

UISelectItems Properties<br />

Writing Bean Properties<br />

UISelectItems components are children of UISelectMany and UISelectOne components.<br />

Each UISelectItems component is composed of either a set of SelectItem instances or a set of<br />

SelectItemGroup instances. As described in “Using the selectItems Tag” on page 345,a<br />

SelectItemGroup is composed of a set of SelectItem instances. This section describes how to<br />

write the properties for selectItems tags containing SelectItem instances and for<br />

selectItems tags containing SelectItemGroup instances.<br />

Chapter 12 • Developing with <strong>Java</strong>Server FacesTechnology 383

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

Saved successfully!

Ooh no, something went wrong!