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

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"/> ...

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