O'Reilly logo

Java Enterprise in a Nutshell, Third Edition by William Crawford, Jim Farley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ResultSets and RowSets, 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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required