Sun Java Studio Creator 2 – Online Help
 

Binding a Table Component to a Database

See Also | Tutorials

When you bind a Table component to a database, you create a connection between the Table component and a database table. After you bind, check the table layout as desribed below to ensure that the columns are displayed in the correct order.

To set up the database table and component:

  1. Add the table component to the page.
     
  2. If you are not connected to the database, in the Servers window, connect now.
     
  3. Expand the Tables or Views node to see the tables or views in the database.
     

To drop a database table on the Table component:

To bind a Table component to a database table that has already been added to the page:

  1. Select the entire Table component.
     
  2. Right-click and choose Bind to Data.
     
  3. In the Bind to Data dialog box, choose the data provider to which you want to bind the Table component and click OK.
     
    When the dialog box closes, the Table component reformats to show the same columns as the database table.
     

To check and adjust the table layout:

  1. In the Visual Designer, right-click the border of the table and choose Table Layout.
     
  2. In the Table Layout dialog box, select columns from the Available list on the left side.
     
  3. Move the columns to be displayed in your application to the Selected list by selecting each column and clicking the > button.
     
  4. Move the columns that you do not want to display out of the Selected list by selecting each column and clicking the < button.
     
  5. You can change the order of the columns by selecting a column and clicking Up or Down.
     
  6. When the Selected list shows the columns in the desired order, click OK.
     
    In the Visual Designer, you see the columns displayed in the Table component. Each column shows the data for the database column it displays.
     
See Also
About Binding Components to Data
Bind to Data Dialog Box: Table Component
About Components and Data
Adding Components to a Page
Adding a Data Source
Adding Database Tables and Views to a Page
JavaServer Faces Expression Language
Tutorials
Using Table Components Tutorial
Working With Databases Tutorial
Using Databound Components to Access Databases Tutorial
 
 
 
Legal Notices. Copyright © 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Close