Binding a Visual Web JSF List Component to a Database

See Also

During Visual Web JSF development, when you bind a list component to a database, you create a connection between the component and at least one column in a database table. List components display one or more values at a time and include the following components from the Basic category of the Palette: Listbox, Drop Down List, Checkbox Group, and Radio Button Group.

First, set up the list component and database table in the IDE. Then, decide whether to drop the database table directly on the component or to drop the database table on the page and then bind the database table to the component. If you drop the database table directly on the component, the component is bound to the values in the first non-key column of the database table. To bind the component to another column, drop the database table on the page and then bind the component to a column of the database table.

To set up the database table and component:

  1. Add the list component to the page.
  2. If you are not connected to the desired database, in the , connect now.
  3. Expand the Tables node to see the tables in the database.

To drag and drop a database table onto a component:

To drag and drop a database table onto the page and then bind the database table to a component:

  1. Drag the database table from the Services window and drop it onto the page.
  2. Select the component to which you want to bind the data and choose Bind to Data.
  3. In the Bind to Data dialog box, select the Bind to Data Provider tab.
  4. In the Bind to Data Provider tab, in the Value field box, select the column to be returned to the database. This column usually contains primary keys.
  5. In the Display field box, select the column to use to display in the component at runtime.
  6. Click OK.
See Also
About Binding Components to Data
Bind to Data Dialog Box: List Component
About Components and Data
Adding Components to a Visual Web JSF Page
Adding a Database Connection
Adding Tables to a Visual Web JSF Page
JavaServer Faces Expression Language

Legal Notices