/** * Reset the action context. */ private void resetActionContext() { ActionContext.setContext(null); }
protected static void cleanUp(ServletRequest req) { // should we clean up yet if (req.getAttribute(COUNTER) != null && ((Integer)req.getAttribute(COUNTER)).intValue() > 0 ) { return; } // tear down the component manager if it was created ComponentManager componentManager = (ComponentManager) req.getAttribute(ComponentManager.COMPONENT_MANAGER_KEY); if (componentManager != null) { componentManager.dispose(); } // always clean up the thread request, even if an action hasn't been executed ActionContext.setContext(null); }
public static OgnlValueStack getStack(PageContext pageContext) { HttpServletRequest req = (HttpServletRequest) pageContext.getRequest(); OgnlValueStack stack = (OgnlValueStack) req.getAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY); if (stack == null) { stack = new OgnlValueStack(); HttpServletResponse res = (HttpServletResponse) pageContext.getResponse(); DispatcherUtils.initialize(pageContext.getServletContext()); DispatcherUtils du = DispatcherUtils.getInstance(); Map extraContext = du.createContextMap(new RequestMap(req), req.getParameterMap(), new SessionMap(req), new ApplicationMap(pageContext.getServletContext()), req, res, pageContext.getServletContext()); extraContext.put(ServletActionContext.PAGE_CONTEXT, pageContext); stack.getContext().putAll(extraContext); req.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY, stack); // also tie this stack/context to the ThreadLocal ActionContext.setContext(new ActionContext(stack.getContext())); } else { // let's make sure that the current page context is in the action context Map context = stack.getContext(); context.put(ServletActionContext.PAGE_CONTEXT, pageContext); AttributeMap attrMap = new AttributeMap(context); context.put("attr", attrMap); } return stack; }
/** * Service an action from the <tt>event</tt> phase. * * @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest, * javax.portlet.ActionResponse) */ public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { LOG.debug("Entering processAction"); resetActionContext(); try { serviceAction(request, response, getActionMapping(request), getRequestMap(request), getParameterMap(request), getSessionMap(request), getApplicationMap(), portletNamespace, EVENT_PHASE); LOG.debug("Leaving processAction"); } finally { ActionContext.setContext(null); } }