Java Reference
In-Depth Information
<b>
Ê
<fmt:formatDate type="both" date
Style="full"
value="${actionBean.date}"/>
</b>
</p>
<p>
Ë
<s:link beanclass="stripesbook.action.H
elloActionBean"
event="currentDate">
Show the current date and time
</s:link>
|
<s:link beanclass="stripesbook.action.HelloActionBean"
event="randomDate">
Show a random date and time
</s:link>
</p>
</body>
</html>
After the standard
page
directive that declares the page as a Java JSP,
the
taglib
directives import the Stripes tag library and the JSTL's for-
matting tags. I'll use the prefix
s
to represent the Stripes tag library;
most people use either
s
or
stripes
. The
fmt
prefix is standard for the
JSTL's formatting tags.
The code at
Ê
displays the value of the
date
property from
HelloAction-
Bean
. The
${actionBean.date}
expression calls the
getDate
( ) method on
the current action bean, and the
<fmt:formatDate>
tag formats the
result by displaying both the date and the time in full.
At
Ë
, the <s:link> tag creates a link to the
currentDate
( ) event handler
of
HelloActionBean
. Notice how clear this is in the tag: the
beanclass=
attribute contains the fully qualified class name of the action bean,
and
event=
tells us the name of the method. The link to
randomDate
( )
is created in the same way. When we read this code, we know exactly
which class and method is called by each link.
Just like that, we've made two types of bindings from the JSP to the
action bean: reading data and triggering an event handler, as illustrated
that are bound to event handlers on
HelloActionBean
, which change the
date and redisplay the page by returning a forward resolution back to
hello.jsp
. Let's talk a little more about these two key concepts: event
handlers and resolutions.
Search WWH ::
Custom Search