Java Reference
In-Depth Information
public
enum Section {
MessageList("Messages", MessageListActionBean.
class
),
ContactList("Contact List", ContactListActionBean.
class
),
Compose("Compose", MessageComposeActionBean.
class
);
private
String text, beanclass;
Section(String text, Class<?
extends
ActionBean> beanclass) {
this
.text = text;
this
.beanclass = beanclass.getName();
}
public
String getText() {
return
text; }
public
String getBeanclass() {
return
beanclass; }
}
}
The default event handler forwards to
menu.jsp
. This is where we display
the menu:
<c:forEach var="section" items="${actionBean.sections}">
<c:choose>
Ê
<c:when test="${section eq actionBean.currentSection}">
<span class="currentSection">
${section.text}
</span>
</c:when>
<c:otherwise>
Ë
<s:link beanclass="${section.beanclass}" class="sectionLink">
${section.text}
</s:link>
</c:otherwise>
</c:choose>
</c:forEach>
The JSP goes through the sections provided by
MenuViewHelper
. The test
at
Ê
determines whether the section is currently selected and displays a
highlighted label in that case. Otherwise, a link to the section is created
at
Ë
, using the action bean class name and text. With the event omitted,
the link uses the default event handler of the action bean.
The menu view helper is now ready to use. How do we embed it in the
"menu"
component
of
layout_menu.jsp
?
The
standard
JSP
tag
<jsp:include>
issues a request and includes the response within the
original JSP.
Search WWH ::
Custom Search