You can use several types of selection list components on a Faces
JSP page. You can drag combo boxes, list boxes, radio buttons, and check boxes
to your page and then dynamically bind them to your data source.
Additional details:
For dynamic values, the list
of choices is produced by one or more selectitem or selectitems tags.
The value attribute of the selectitems tag
points to the data element that contains the choices. The selectitems tag
expects one of the following forms of data:
- A java.util.Collection of javax.faces.component.SelectItem member
objects. The SelectItem class defines a simple container
that holds label, value, and description for an individual choice.
- An array of javax.faces.component.SelectItem
For any other data types, the tool generates a
value to
translate the data into one of these desired forms. The
value will
have the form
selectitems.bean.label.value.toArray where:
- selectitems is a special keyword to identify this translation
case
- bean identifies something JavaBean-like in the data model.
It might be a multi-level reference such as aaa.bbb.ccc,
and can resolve to any Object, including Collection types.
- label is a property of the object identified by bean.
The value of this property is what is displayed as a choice.
- value is another property of bean and
is set with the selected choice. By default, this is the same as label).
- toArray is a keyword to terminate the special reference
string.
When you bind from the Page Data view, selecting an individual field
always creates a
value that uses the same field for both
label and value. To use different strings for the UI label and passed value,
modify the
value manually according to the pattern above.
Examples of
value attributes for the
selectitems tag:
- myBean.choices binds a SelectItem[] property choices from
a bean called myBean.
- selectitems.EMPLOYEES.NAME.NAME.toArray binds the String
property NAME from a Data List called EMPLOYEES
- selectitems.anotherBean.choices.choices.toArray binds
a String array called choices from a JavaBean called anotherBean.
- selectitems.EMPLOYEE.NAME.EMPID.toArray manually binds
employee names from a Record List called EMPLOYEES, using
the employee ID for the selected value.