Java Reference
In-Depth Information
It's now very clean and simple to retrieve the currently selected folder.
Action beans can call getContext().getCurrentFolder ( ), and JSPs can use
${actionBean.context.currentFolder} .
Neither
has
to
bother
with
the
session-tinkering details.
The layout_folders.jsp file can now display the list of folders, using the
currently selected folder to determine where to place the arrow:
Download email_19/web/WEB-INF/jsp/common/layout_folders.jsp
<jsp:useBean class="stripesbook.view.FoldersViewHelper" id="folders"/>
<!-- ... -->
<s:layout-definition>
<!-- ... -->
<div id="folders">
<d:table name="${folders.folders}" id="folder">
<d:column title="Name">
<s:link
beanclass="stripesbook.action.MessageListActionBean">
<s:param name="folder" value="${folder.id}"/>
${folder.name}
</s:link>
<c:if test="${actionBean.context.currentFolder eq folder}">
<img src="${contextPath}/images/arrow.png"
style="border: none; vertical-align: bottom"/>
</c:if>
</d:column>
<d:column title="Messages" style="text-align: right">
${fn:length(folder.messages)}
</d:column>
</d:table>
</div>
<!-- ... -->
</s:layout-definition>
We've also created links on the names of the folders. Clicking a folder
name changes the selected folder and displays the messages it con-
tains. This has to work across all pages that use layout_folders.jsp , so
we add the setter method that changes the currently selected folder in
BaseActionBean :
Download email_19/src/stripesbook/action/BaseActionBean.java
public void setFolder(Folder folder) {
getContext().setCurrentFolder(folder);
}
Now the currently selected folder will be changed with the <s:param>
tag that we used, with the folder= parameter name and the folder Id as
a value. With a type converter, the Id is automatically converted to a
Folder object.
 
Search WWH ::




Custom Search