Building Tables
JSF provides two mechanisms for generating tables.
Panel grids allow you to organize multiple JSF
components into an HTML table and are useful for laying out data entry
forms and other pages for which you know the number of components but
want to leave the mechanics of HTML formatting to the JSF engine.
Data grids allow you to build tables based on
variable numbers of objects—list objects, ResultSet
s and RowSet
s, and JSF DataModel
objects.
Panel Grids
The Book Details form uses the <h:panelGroup>
and <h:panelGrid>
tags to group and
display multiple JSF tags. The <h:panelGroup>
tag is very simple—it
groups a set of JSF components into a single unit. Decisions about
which components to display can then be handled at the group level
rather than component by component. Back in Example 5-6, we grouped an
<h:panelGrid>
(for book
information) and an <h:panelGroup>
(containing two
additional panel groups for control buttons) into a parent <h:panelGroup>
. The top-level group
controls rendering of all book information based on whether a book
is selected.
The <h:panelGrid>
component allows you to apply table formatting to a set of components. The tag allows the designer to specify a number of columns and then builds a table with the specified number of columns and as many rows as are required to accommodate the set of components provided by the page designer. In our example, we have two columns and eight components, so the JSF engine renders a table with two columns and four rows: ...
Get Java Enterprise in a Nutshell, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.