Bind to Data Dialog Box: List Component

See Also

This dialog box enables you to associate a data provider or object with the component's items property, which displays the list items in the component. You can create this association if you want to change the items in the component's list at runtime.

The dialog box opens when you right-click a Basic Listbox, Checkbox Group, Radio Button Group, or Drop Down List component that you have added to a Visual Web JSF page and choose Bind to Data.

The top field of the dialog box shows you the current setting for the component's items property. By default, this property is bound to the options property of the default object that populates the list. For example, for a drop down list named dropDown1, this object would be dropDown1DefaultOptions.

To set a binding, first choose the tab that does the kind of binding you want, Bind to Data Provider or Bind to Object.

Bind to Data Provider

This tab enables you to bind the component property to a database column that you added to the page prior to accessing this dialog box.

If the displayed data provider is not the one you want to use, select another data provider from the Choose a Data Provider drop down list. If you do not see the data provider listed, you must add a database table to the page, as appropriate for your application.

When you have selected the data provider you want, the Value Field and Display Field lists are populated with items from the data provider. Depending on the object represented by the data provider, the items in these lists can represent database columns, web service methods, or enterprise bean methods. The two columns represent different aspects of the list items displayed by the component on your page.

Select the items that will populate your component's list.

When you select an item, the dialog box's top entry field is filled in for you with a JavaServer Faces expression that references the item you selected.

When you are satisfied with your selection, click OK to apply the binding to the component's items property.

Bind to an Object

This tab enables you to bind the component property to a JavaBeans property. If you like, you can create your own JavaBeans objects to control the list items. You bind to a property by selecting the property and clicking OK.

By default, the items property of a list component is bound to the options property of an object that the IDE creates to populate the list. You typically work with this object by right-clicking the component in the page and choosing Configure Default Options. You can also create your own object to populate the list.

For example, the JavaBeans object created for a JavaServer Faces 1.2 drop down list named dropDown1 is named dropDown1DefaultOptions. The Options property of this object is an array of com.sun.webui.jsf.model.Option objects, each of which has two fields, label of type String, the displayed value in the list, and value of type Object, the value of the list item.

See Also
Checkbox Group Component
Drop Down List Component
Listbox Component
Radio Button Group Component
About Binding Components to Data
About Components and Data

Legal Notices