With the Data Table component, you can display data from a database
or other data source in a table format.
There are several ways to add a data table to a Faces JSP file:
- Drag a Data Table component from the Faces Components drawer on the palette
to a Faces JSP page, add columns to the table, add Faces components to the
columns, and then bind data to the table and the components it contains. You
can use the Value field in various Properties views
to bind data. This is the most difficult way to add a data table to a page.
- Drag a relational record list from the Data drawer on the palette to a
page. The "Add Relational Record List" wizard opens. This wizard allows you
to add a data table to the page and bind it to data from a relational record
list. Make sure to check the Add data controls option
in the wizard so that a data table is added to the page.
- Drag an existing relational record list from the Page Data view to the
page. The "Insert Record List" wizard opens. This is the way that the following
steps describe.
To automatically add a data table that is bound to an existing relational
record list:
- Open a Faces JSP file.
- Open the Page Data View ().
- Drag an existing relational record list in the Page Data view to
the Faces JSP file. The "Insert Record List" wizard opens.
Note: If
you do not have an existing relational record list, right-click within the
Page Data view and choose . The "Add Relational Record List" wizard
opens.
- Next to Data control to create, select the
type of data table you want to create. The default is a multi-column data
table so that you have one row for each data entry.
- Under Columns to display, check the columns
you want to appear in the data table. You can also change the accessibility
label and change the default control type (for example, you can change an
input field to a combo box field).
- Click Options for additional accessibility
options.
- Click Finish. The data
table is added to the page.
- To set additional properties for the data table:
- At the Properties view for the data table (dataTable), add a header
and footer to the data table by checking Show header and Show
footer. A header displays along the top of the data table and
a footer along the bottom of the data table. Each contains a Panel Box component
to which you can drag other Faces components. For example, you can drag an
Output component onto the Panel Box component to give the data table a name.
- At the Display option tab of the Properties
view for the data table, you can set a way for users to page through the table
if it contains a large number of records. For example, if you click Add
a Web style pager, a pager is created in the footer of the data
table. The pager displays a series of page numbers with hyperlinks to the
appropriate pages
- At the Row actions tab of the Properties view
for the data table, you can add actions that execute when a row on a table
is clicked or add an action that executes on selected rows in a table.
To learn more about adding and configuring data tables and about
relational record lists, do the following tutorial:
Tutorial: Display dynamic information on Web pages with JavaServer Faces. This
tutorial will teach you how to design a dynamic Web site that functions as
a newspaper's classified advertising section. The Web site is a complete J2EE
Web application that uses JavaServer Faces (JSF) components and Service Data
Objects (SDO) components. The Web application uses JSF technology to create
dynamic Web pages that link to a database that stores classified advertising
data.Tutorial:
Display dynamic information on Web pages with JavaServer Faces. This tutorial
will teach you how to design a dynamic Web site that functions as a newspaper's
classified advertising section. The Web site is a complete J2EE Web application
that uses JavaServer Faces (JSF) components and Service Data Objects (SDO)
components. The Web application uses JSF technology to create dynamic Web
pages that link to a database that stores classified advertising data.