O'Reilly logo

JavaServer Faces by Hans Bergsten

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

Chapter 10. Working with Tabular Data

Almost all applications deal with tabular data of some kind. An application management tool typically shows a list with statistics for installed applications and allows an operator to start and stop applications from the list, and a human resource application may display a list of employees and let an administrator select and edit the profile for any one of them. The sample application we develop in this book works with two sets of tabular data: the list of all expense reports and the list of entries for an individual report.

In this chapter, we look at different ways to display and manipulate tabular data, ranging from displaying a simple read-only listing to developing an editable table.

Displaying a Read-Only Table

With Java, you can represent tabular data in many different ways. Commonly, it's represented as a java.util.List or array with beans or java.util.Map instances representing the columns for each row. If the data is stored in a database, a java.sql.ResultSet or a JSTL javax.servlet.jsp.jstl.sql.Result object typically represents it.

The JSTL <c:forEach> action supports looping over all these data types, with the exception of java.sql.ResultSet, so if all you need is rendering a read-only list or table, you can use JSTL just as you would in a regular JSP page. I actually used this approach in Chapter 8, to verify that the entries added by the action method for the Add button in the report entry form actually were added to the list: ...

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