Java Reference
In-Depth Information
Support for Action Beans
A base class for action beans implements the
ActionBean
interface:
package
stripesbook.action;
public abstract class
BaseActionBean
implements
ActionBean {
private
ActionBeanContext actionBeanContext;
public
ActionBeanContext getContext() {
return
actionBeanContext;
}
public void
setContext(ActionBeanContext actionBeanContext) {
this
.actionBeanContext = actionBeanContext;
}
}
When you add an action bean, you can just extend this class and get
on with your business.
BaseActionBean
is also the place to put any other
common code that you might want to reuse in all action beans.
Support for JSPs
For JSPs, it's nice to have all the tag library declarations in one place,
such as in this
taglibs.jsp
file:
<%@taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="contextPath" value="${pageContext.request.contextPath}"/>
Besides importing the Stripes tag library and the JSTL, I've added
a shortcut to the context path. Being a lazy typist, I prefer to use
${contextPath}
whenever I need the context path, instead of
${pageCon-
text.request.contextPath}
.
Now, we get the tag libraries and the context path shortcut in a JSP
with just one line:
<%@include file="/WEB-INF/jsp/common/taglibs.jsp"%>
Finally, you'll appreciate having a JSP that provides a layout that's
reused for every page of the application. It saves you from copying and
pasting boilerplate HTML code and gives your pages a consistent look
and feel.
Search WWH ::
Custom Search