The UISelectMany Component
The UISelectMany Component
The value attribute of the selectItems tag is bound to the newsletters managed bean, which
is configured in the application configuration resource file. The newsletters managed bean is
configured as a list:
<managed-bean>
<managed-bean-name>newsletters</managed-bean-name>
<managed-bean-class>
java.util.ArrayList</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
<list-entries>
<value-class>javax.faces.model.SelectItem</value-class>
<value>#{newsletter0}</value>
<value>#{newsletter1}</value>
<value>#{newsletter2}</value>
<value>#{newsletter3}</value>
</list-entries>
</managed-bean>
<managed-bean>
<managed-bean-name>newsletter0</managed-bean-name>
<managed-bean-class>
javax.faces.model.SelectItem</managed-bean-class>
<managed-bean-scope>none</managed-bean-scope>
<managed-property>
<property-name>label</property-name>
<value>Duke
's Quarterly</value>
</managed-property>
<managed-property>
<property-name>value</property-name>
<value>200</value>
</managed-property>
</managed-bean>
...
As shown in the managed-bean element, the UISelectItems component is a collection of
SelectItem
instances. See
for more
information on configuring collections as beans.
You can also create the list corresponding to a UISelectMany or UISelectOne component
programmatically in the backing bean. See
for
information on how to write a backing bean property corresponding to a UISelectMany or
UISelectOne
component.
The arguments to the SelectItem constructor are:
An Object representing the value of the item
A String representing the label that displays in the UISelectMany component on the page
A String representing the description of the item
Adding UI Components to a Page Using the HTML Component Tags
The Java EE 5 Tutorial · September 2007
348