Java Reference
In-Depth Information
Joe Asks. . .
Why Not Just Use a context.currentFolder Parameter to
Change the Currently Selected Folder?
We added a setter method on BaseActionBean to set the cur-
rently selected folder on the MyActionBeanContext object:
public void setFolder(Folder folder) {
getContext().setCurrentFolder(folder);
}
The folder is retrieved in the JSP with ${action-
Bean.context.currentFolder} , so why not use the same parameter
to change the value, like this?
<s:link ...>
<s:param name="context.currentFolder" value="${folder.id}"/>
...
</s:link>
This won't work because setting a value on an ActionBean-
Context object from a request parameter is blocked by Stripes
for security purposes. Indeed, ActionBeanContext contains all
the information concerning the current request and response,
so it would be unsafe to allow users to bind into this object
with context.xx parameters. Imagine what would happen if
any user could gain administrator access just by adding con-
text.user.admin=true to the end of a URL! Binding indirectly, as we
did for the currently selected folder, ensures that nothing funny
is going on behind your back.
The message_list.jsp file renders the layout_folder.jsp layout to include the
list of folders and uses ${actionBean.context.currentFolder} to obtain the
current folder and display the messages that it contains:
Download email_19/web/WEB-INF/jsp/message_list.jsp
<c:set var="folder" value="${actionBean.context.currentFolder}"/>
<s:layout-render name="/WEB-INF/jsp/common/layout_folders.jsp"
title="Message List" currentSection="MessageList">
<s:layout-component name="body">
<d:table name="${folder.messages}" requestURI="" id="message"
pagesize="10" defaultsort="2" defaultorder="descending">
<d:column title="Date" sortable="true">
<s:format value="${message.date}"
formatPattern="yyyy-MM-dd HH:mm"/>
</d:column>
 
 
Search WWH ::




Custom Search