Binding a Simple Visual Web JSF Component to a Database

See Also

During Visual Web JSF development, when you bind a simple component to a database, you create a connection between the component and a column in a database table. Simple components display one value at a time. For easiest data binding, use components from the Basic category of the Palette, such as Button.

First, set up the 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 first value in the first column of the database table. To bind the component to another column, drop the component on the page and choose the column.

To set up the database table and component:
  1. Add the component to the page.
  2. If you are not connected to the correct database, in the , connect now.
  3. In the database-name node, expand the Tables node.

To drag and drop the database table on the component:

To drag and drop the database table on the page and then bind it to the component:

  1. Drag and drop the database table from the Services window to the Visual Designer.
  2. Right-click the component to which you want to bind the data and choose Bind to Data.
  3. In the dialog box, choose the Bind to Data Provider tab.
  4. Select the data provider and data field to which you want to bind the component and click OK.

    For example, in the Services window, open Databases > Travel > Tables and drag the TRIPTYPE table to the page. Then, select a button and choose Bind to Data. In the Bind to Data dialog box, select the triptypeDataProvider and the TRIPTYPE.NAME column and click OK. At runtime, the button displays TRNG, which is the value in the first row in the NAME column of the TRIPTYPE table.

See Also
About Binding Components to Data
Bind to Data Dialog Box: Simple Display 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