Java Reference
In-Depth Information
F IGURE 33.10
A New JSF page CurrentTime was created.
5 xmlns:h="http://xmlns.jcp.org/jsf/html">
6 <h:head>
7 <title>Display Current Time</title>
8 <meta http-equiv="refresh" content ="60" />
9 </h:head>
10 <h:body>
11 The current time is #{timeBean.time}
12 </h:body>
13 </html>
refresh page
JSF expression
Line 8 defines a meta tag inside the h:head tag to tell the browser to refresh every 60 seconds.
This line can also be written as
<meta http-equiv="refresh" content ="60"></ meta>
An element is called an empty element if there are no contents between the start tag and end
tag. In an empty element, data are typically specified as attributes in the start tag. You can
close an empty element by placing a slash immediately preceding the start tag's right angle
bracket, as shown in line 8, for brevity.
Line 11 uses a JSF expression #{timeBean.time} to obtain the current time. timeBean
is an object of the TimeBean class. The object name can be changed in the @Named annotation
(line 6 in Listing 33.2) using the following syntax:
empty element
@Named(name = "anyObjectName")
By default, the object name is the class name with the first letter in lowercase.
Note that time is a JavaBeans property because the getTime() method is defined in
TimeBeans . The JSF expression can either use the property name or invoke the method to
obtain the current time. So the following two expressions are both fine.
#{timeBean.time}
#{timeBean.getTime()}
The syntax of a JSF expression is
#{expression}
 
 
Search WWH ::




Custom Search