background image

The UISelectItem Component

<< Rendering Components for Selecting Multiple Values | The selectItems Tag >>
<< Rendering Components for Selecting Multiple Values | The selectItems Tag >>

The UISelectItem Component

<h:selectManyCheckbox
id=
"newsletters"
layout=
"pageDirection"
value=
"#{cashier.newsletters}">
<f:selectItems
value=
"#{newsletters}"/>
</h:selectManyCheckbox>
The value attribute of the selectManyCheckbox tag identifies the CashierBean backing bean
property, newsletters, for the current set of newsletters. This property holds the values of the
currently selected items from the set of check boxes. You are not required to provide a value for
the currently selected items. If you don't provide a value, the first item in the list is selected by
default.
The layout attribute indicates how the set of check boxes are arranged on the page. Because
layout is set to pageDirection, the check boxes are arranged vertically. The default is
lineDirection
, which aligns the check boxes horizontally.
The selectManyCheckbox tag must also contain a tag or set of tags representing the set of check
boxes. To represent a set of items, you use the selectItems tag. To represent each item
individually, you use a selectItem tag for each item. The following subsection explains these
tags in more detail.
The UISelectItem, UISelectItems, and
UISelectItemGroup
Components
UISelectItem
and UISelectItems represent components that can be nested inside a
UISelectOne
or a UISelectMany component. UISelectItem is associated with a SelectItem
instance, which contains the value, label, and description of a single item in the UISelectOne or
UISelectMany
component.
The UISelectItems instance represents either of the following:
A set of SelectItem instances, containing the values, labels, and descriptions of the entire
list of items
A set of SelectItemGroup instances, each of which represents a set of SelectItem instances
Figure 11­6
shows an example of a list box constructed with a SelectItems component
representing two SelectItemGroup instances, each of which represents two categories of beans.
Each category is an array of SelectItem instances.
Adding UI Components to a Page Using the HTML Component Tags
The Java EE 5 Tutorial · September 2007
346