Using a Panel Component for Layout

The JSP pages for the other two views follow the same pattern as the first one, as shown in Example 9-3 and Example 9-4.

Example 9-3. Language selection page with Previous, Next and Cancel buttons (expense/stage1/prefLang.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>
  <html>
    <body>
      <h2>Language:</h2>
      <h:form>
        <h:panelGrid columns="2">
          <h:outputText value="Language:" />
          <h:selectOneRadio value="#{userProfile.locale}">
            <f:selectItem itemValue="sv" itemLabel="Swedish"/>
            <f:selectItem itemValue="en" itemLabel="English"/>
          </h:selectOneRadio>
        </h:panelGrid>

                          <h:commandButton value="Previous" 
                            immediate="true" action="previous" />
                          <h:commandButton value="Next" 
                            action="#{userHandler.updateProfile}" />
                          <h:commandButton value="Cancel" 
                            immediate="true" action="cancel" />
      </h:form>
    </body>
  </html>
</f:view>
Example 9-4. Font selection page with Previous, Done and Cancel buttons (expense/stage1/prefFont.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>
  <html>
    <body>
      <h2>Fonts:</h2>
      <h:form>
        <h:panelGrid columns="2"> <h:outputText value="Font style:" /> <h:selectOneMenu value="#{userProfile.fontStyle}"> <f:selectItem itemValue="serif" itemLabel="Serif"/> <f:selectItem itemValue="san-serif" itemLabel="San-Serif"/> ...

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.