01: package org.apache.struts.action;
02:
03: import javax.servlet.http.HttpServletRequest;
04: import javax.servlet.http.HttpSession;
05:
06: import org.apache.struts.StrutsConstants;
07:
08: /**
09: * CommandUtils
10: * Utility class used by PortletStrutsLife.java to
11: * save/retrieve (Forward/include/ForwardConfig)command
12: * in user session.
13: * These command provide information to render method
14: * about next view page.
15: */
16: public class CommandUtils {
17:
18: static private String getSavedCommandID(HttpServletRequest request) {
19: String savedCommandID = request
20: .getParameter(StrutsConstants.SAVED_COMMAND_ID);
21: if (savedCommandID == null) {
22: savedCommandID = StrutsConstants.SAVED_COMMAND_ID;
23: }
24: return savedCommandID;
25: }
26:
27: static public void saveStrutsCommand(HttpServletRequest request,
28: StrutsCommand savedAction) {
29: String savedActionID = getSavedCommandID(request);
30: HttpSession session = request.getSession();
31: session.setAttribute(savedActionID, savedAction);
32: }
33:
34: static public StrutsCommand getStrutsCommand(
35: HttpServletRequest request) {
36: String savedActionID = getSavedCommandID(request);
37: HttpSession session = request.getSession();
38: return (StrutsCommand) session.getAttribute(savedActionID);
39: }
40: }
|