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

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="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

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

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