HTML and CSS Reference
In-Depth Information
Listing 2-25.
The Initial Code of the confirm.xhtml Page
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="
http://www.w3.org/1999/xhtml
"
xmlns:ui="
http://java.sun.com/jsf/facelets
"
xmlns:h="
http://java.sun.com/jsf/html
"
>
<ui:composition template="/WEB-INF/templates/simple.xhtml">
<ui:define name="title">
#{bundle['survey.confirm.page']}
</ui:define>
<ui:define name="content">
<h:form>
<h:outputText value="#{bundle['survey.information.confirm']}"/>
<h:panelGrid columns="2">
<h:outputText value="#{bundle['survey.user.name']}"/>
<h:outputText value="#{flash.userName}"/>
<h:outputText value="#{bundle['survey.user.age']}"/>
<h:outputText value="#{flash.age}"/>
<h:outputText value="#{bundle['survey.user.sex']}"/>
<h:outputText value="#{flash.sex}"/>
<h:outputText value="#{bundle['survey.user.monthyIncome']}"/>
<h:outputText value="#{flash.monthlyIncome}"/>
<h:outputText value="#{bundle['survey.user.yearlyTravelAbroad']}"/>
<h:outputText value="#{flash.travelsAbroad}"/>
<h:outputText value="#{bundle['survey.user.oftenTravelBy']}"></h:outputText>
<h:outputText value="#{flash.travelBy}"/>
</h:panelGrid>
<h:commandButton value="#{bundle['survey.actions.save']}"
action="#{survey.save}"/>
<h:commandButton value="#{bundle['survey.actions.modify']}"
action="input?faces-redirect=true"/>
<br/><br/>
</h:form>
</ui:define>
</ui:composition>
</html>
The confirmation page displays all of the entered survey information using the
#{flash.attributeName}
. From
this page, the user can either save the entered information and navigate to the
final.xhtml
page or modify the
information in the
input.xhtml
page.
However, if you click the
"Modify" commandButton
in order to modify the entered information, you will find the
input.xhtml
fields are empty (in other words, the flash information is lost), which is logical because the
flash
scope
life ends once the
confirm.xhtml
page is rendered. In order to resolve this issue, all you need to do to keep the flash