See Also | Tutorials
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:
- Add the list component to the page.
- If you are not connected to the desired database, in the Servers window, connect now.
- Expand the Tables or Views node to see the tables or views in the database.
To drop the database table on the component:
- Drag the database table or view from the Servers window and drop it onto the list component
in the Visual Designer.
At runtime, the list component displays the values in the first non-key column
of the database table.
For example, in the Servers window, open Data Sources > Travel > Tables and drag the TRIPTYPE table and drop it on a
listbox. At runtime, the listbox displays
all the values in the first non-key column of the TRIPTYPE table, that is, the
NAME column, which has values like TRNG, SALES, OTHER, and so on.
To drop the database table on the page and then bind the database table to the component:
- Drag the database table or view from the Servers window and drop it onto the page.
- Select the component to which you want to bind the data and choose Bind to Data.
- In the Bind to Data dialog box, select the Bind to Data Provider tab.
- 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.
- In the Display field box, select the column to use to display in the component at runtime.
- Click OK.
- See Also
- About Binding Components to Data
- Bind to Data Dialog Box: List Component
- About Components and Data
- Adding Components to a Page
- Adding a Data Source
- Adding Tables and Views to a Page
- JavaServer
Faces Expression Language
- Tutorials
- Delving Into Components Tutorial
- Working With Databases Tutorial
- Using Databound Components to Access Databases Tutorial