Adding selection lists to a Faces JSP file

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.

You can add the following selection list components. Note that they all have similar properties in their Properties views.

To add a selection component to your Faces JSP page:

  1. Drag one of the selection list components to your Faces JSP page.

  2. Open the Properties view for the selection list component.

  3. In the Value field, you can bind to a data source so that the current value can be displayed or the value for a specific record field can be changed. For example, if you are creating a new employee record, you might have a selection list to choose the department or the city and the value you choose becomes part of the new employee record.

  4. For a check box or radio button, specify Horizontal or Vertical in the Direction field of the Properties view, or accept the default. For a list box, specify the height in number of lines.

  5. In addition to static choices, you can add dynamic choices to the selection component. Dynamic choices get their value from your data source.

    1. Click Add Choice orAdd Set of Choices. An entry is added to the Name column.

    2. To edit the name of the entry, click the name in the Name column so that you can edit it.

    3. If you want to bind the new entry to a data value, click within the Value cell and then click the button that displays in the cell. The Select Page Data Object dialog opens.

    4. Select a property from a record list to bind to the choice or set of choices and click OK. (Note that the data source must already have been defined.) At run time, a list derived from your data source is displayed.

    5. To remove a choice, select the choice and click Remove Choice. To move choices in the list, select the choice and click Move Up or Move Down.

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:

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:

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:

To view several limitations on Faces Web applications, including one on field focus in Internet Explorer for radio buttons and check boxes, see Limitations: Faces JSP applications.

 

Related concepts

Faces components
Data access for Faces components

 

Related tasks

Creating Faces applications - overview
connection, the user of your Web site can read data from an existing data source, write new data to the data source, and update and delete data.">Creating a connection to a relational database

Related reference
Faces components reference
Faces attributes reference