Processing Row-Specific Events

A very common application feature is to have one table with summary information (a master table) with each row linked to the details about the item in that row. The sample application uses this approach for selecting an individual report to work with. To implement this feature, you must figure out which master table row the user selected and make the corresponding details available for edit or display.

In the final version of the sample application, both the master table and the details are displayed on the same screen, but let’s look at how to implement it using two screens first, so we can focus on one thing at the time. Figure 10-1 shows the first rough cut of the reports list screen, with the report titles as links to a report details screen.

Simple reports list screen
Figure 10-1. Simple reports list screen

Example 10-1 shows the JSP page for this initial version.

Example 10-1. Reports list with links (expense/stage1/reportListArea.jsp)
<%@ page contentType="text/html" %>
<%@ taglib uri="" prefix="h" %>
<%@ taglib uri="" prefix="f" %>

    <h:dataTable value="#{reportHandler.reportsModel}" var="report">
        <f:facet name="header">
          <h:outputText value="Title" />
        <h:commandLink action="#{}" immediate="true">
          <h:outputText value="#{report.title}" />
        </h:commandLink> </h:column> ...

Get JavaServer Faces now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.