Java Reference
In-Depth Information
The beanclass Attribute Also Accepts a Class
We're using a String value in the beanclass= attribute to indicate
the fully qualified class name of the action bean. Another way
is to use an expression that resolves to the actual Class of the
action bean.
For example, you could use ${actionBean.class} to refer to the
class of the current action bean:
<s:link beanclass="${actionBean.class}" .../>
This dynamically refers to the current action bean when trigger-
ing event handlers, opening the door to using the same JSP for
more than one action bean. The JSP doesn't need to “know”
which action bean is being used.
Dynamic magic is nice, but there is a drawback. When you
are reading JSP code and you see beanclass="stripesbook.
action.ContactListActionBean" , you know exactly which action
bean handles the request. But beanclass="${actionBean.class}"
just tells you “the current action bean.” It's not obvious which
action bean is associated to the JSP—and there could even
be more than one.
This is great—no need to manually convert String parameters to prim-
itive types and their wrapper classes. Just declare the property using
the desired type in the action bean, and Stripes uses a type converter
to do the necessary conversion.
Now it's simple to retrieve the selected contact by using the DAO and
the contact ID parameter. The JSP can now read the contact with
${actionBean.contact} .
The contact_view.jsp source is quite straightforward. It displays the in-
formation for the selected contact and adds a link at the bottom to
return to the contact list:
Download email_03/web/WEB-INF/jsp/contact_view.jsp
<%@include file="/WEB-INF/jsp/common/taglibs.jsp"%>
<s:layout-render name="/WEB-INF/jsp/common/layout_main.jsp"
title="Contact Information">
<s:layout-component name="body">
<table class="view">
 
 
Search WWH ::




Custom Search