Data table components
The data table is a Faces component you can add to a Faces JSP page to display application data. It is a table-like control for displaying data from multiple database records. It consists of one or more columns, each with a header area and a data area. It is the data area of the column that repeats for each record.
You typically bind a data table to a record list or other data source, and the data table displays the data belonging to that record list. The data table contains columns, which act as containers for Faces components.
There are multiple ways to create a data table.
- Drag a record list from the Page Data View if the data source has already been defined. This is the easiest way to create a data table.
- Drag a record list from the Data drawer of the Palette and then define the data source.
- Drag a data table from the Faces components drawer of the palette to the Faces JSP page. Then, create the columns you'll need, add input, output, or other components to the columns, and bind data to the components in the table. This last method of creating a data table usually takes the most time but does give you design flexibility.
The data table offers great flexibility in how it is rendered on the user interface of your application. You can customize it in a variety of ways:
- Add, remove, and change the order of columns
- Format text and background, Can also modify the css classes for dataTable itself, the columns, rows, header and footer
- Modify the CSS classes for the data table itself and for the columns, rows, header, and footer
- Add header, footer, and margins
- Add paging for results display
You can perform actions such as Read, Update, and Delete on the data displayed in a data table, and you can also create new data records. There are several ways to associate actions with a data table:
- Associate an action with the data table, so that when a user clicks anywhere within a row of a table, the action is applied to the relational record for that row.
- Enable row selection for the data table, and then add buttons to perform actions on the selected rows. You should enable row selection when you want an action to apply to one or more rows. If you want an action to apply to just one row, you can associate an action with the data table (see previous bullet).
- Add a Command - Hyperlink component to another component already in the data table. When the user clicks the Command - Hyperlink component, a different page might open.
- Add an Actions column and then drag Command - Hyperlink components into each row of the column. When the user clicks the Command - Hyperlink component, an action is applied to the selected row. Optionally, the user can go to a different page (for example, a confirmation page).
- Enable row categorization for the data table so that you can group similar rows together so that the end user clicks a twistie to expand or collapse the similar rows.
- Enable row edit for the data table so that the end user has the ability to edit a row.
To learn more about creating and formatting data tables, do the following tutorial: Displaying dynamic information on Web pages with JavaServer Faces
Related concepts
Faces components
Data access for Faces components
Related tasks
Creating Faces applications - overview
Creating a connection to a relational database
header or footer. A header is displayed along the top of the data table and a footer along the bottom of the data table. You can drag other Faces components to the header and footer. For example, if you want a title for the table and an image next to the title, you can drag an Output component and an Image component to the header.">Adding a header and footer to a data table
Managing columns in a data table
Adding paging to a data table
Enabling row selection for a data table
Associating row actions with a data table
Adding row category support to a data table
Adding row edit to a data table
Passing parameters with a data table
Adding hyperlinks to a Faces JSP page
Related reference
Faces components reference
Faces attributes reference