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.
Before binding a list component to a database, you must ensure that the Java DB Database
Server is installed and running. To start the Java DB Database Server, in the main menu,
choose Tools > Java DB Database > Start Java DB Server.
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.
If you are not connected to the desired database, in the , connect
now.
Expand the Tables node to see the tables in the database.
To drag and drop a database table onto a component:
Drag the database table from the Services 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 Services window, open Databases > 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 drag and drop a database table onto the page and then bind the database table to a
component:
Drag the database table from the Services 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.