HTML and CSS Reference
In-Depth Information
In the XHTML page, you can call the calculateAverage method by using #{maths.calculateAverage(10.5,
12.3)}, which outputs 11.4 .
The Flash Scope
The flash scope is a new scope introduced since the JSF 2.0. The flash scope concept is inspired from RoR (Ruby
on Rails). The flash scope means that “anything that is placed in the flash scope will be exposed to the next view
encountered by the same user session and then cleared out.” In other words, the objects in the flash scope will be
available ONLY for the next request of the same browser window .
The flash scope is useful if you want to keep information for a short time for the next request only, whether the
next request will result from an HTTP Redirect, a JSF form postback, or an HTTP GET for a new page. Let's see an
example to understand the flash scope.
The survey application is a simple application that consists of three pages:
input.xhtml , which asks the user for some information that is useful for the survey.
confirm.xhtml , which displays the information entered by the user and asks the user to
confirm or modify it.
final.xhtml , which is a “Thank you” page.
Listing 2-24 shows the input.xhtml page.
Listing 2-24. The input.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 "
xmlns:f=" http://java.sun.com/jsf/core " >
<ui:composition template="/WEB-INF/templates/simple.xhtml">
<ui:define name="title">
#{bundle['survey.input.page']}
</ui:define>
<ui:define name="content">
<h:form>
<h:panelGrid columns="3">
<h:outputText value="#{bundle['survey.user.name']} "></h:outputText>
<h:inputText id="userName"
value="#{flash.userName}"
required="true">
</h:inputText>
<h:message for="userName" styleClass="errorMessage"/>
<h:outputText value="#{bundle['survey.user.age']}"></h:outputText>
<h:inputText id="age"
value="#{flash.age}"
required="true">
<f:convertNumber />
</h:inputText>
<h:message for="age" styleClass="errorMessage"/>
 
Search WWH ::




Custom Search