See Also | Tutorials
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 Text Field.
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:
- Add the component
to the page.
- If you are not connected to the correct database, in the Servers window,
connect now.
- Expand the Tables or Views node.
To drop the database table on the component:
- Drag the database table or view from the Servers window and drop the database table or view on the component
in the Visual Designer.
For example, in the Servers window, open Data Sources > Travel > Tables and drag the TRIPTYPE table and drop it on a button. At runtime, the button displays the value in the first row in the first column of the table. In this example, the first value in the TRIPTYPEID column of the TRIPTYPE table is 1.
To drop the database table on the page and then bind it to the component:
- Drag the database table or view from the Servers window to the Visual Designer.
- Right-click the component to which you want to bind the data and choose
Bind to Data.
- In the dialog box, choose the Bind to Data Provider tab.
- Select the data provider and data field
to which to bind the component and click OK.
For example, in the Servers window, open Data Sources > 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 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