/** * Returns the HTTP page context. * * @return the HTTP page context. */ public static PageContext getPageContext() { return (PageContext) ActionContext.getContext().get(PAGE_CONTEXT); }
/** * Get the default action name for the current mode. * * @return The default action name for the current portlet mode. */ public static String getDefaultActionForMode() { return (String)getContext().get(DEFAULT_ACTION_FOR_MODE); }
protected String handleInvalidToken(ActionInvocation invocation) throws Exception { ActionContext ac = invocation.getInvocationContext(); HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST); HttpServletResponse response = (HttpServletResponse) ac.get(ServletActionContext.HTTP_RESPONSE); String tokenName = TokenHelper.getTokenName(); String token = TokenHelper.getToken(tokenName);
/** * Gets the HTTP servlet request object. * * @return the HTTP servlet request object. */ public static HttpServletRequest getRequest() { return (HttpServletRequest) ActionContext.getContext().get(HTTP_REQUEST); }
/** * Get the action namespace of the portlet. Used to organize actions for multiple portlets in * the same portlet application. * * @return The portlet namespace as defined in <code>portlet.xml</code> and <code>xwork.xml</code> */ public static String getPortletNamespace() { return (String)getContext().get(PORTLET_NAMESPACE); }
/** * Gets the HTTP servlet response object. * * @return the HTTP servlet response object. */ public static HttpServletResponse getResponse() { return (HttpServletResponse) ActionContext.getContext().get(HTTP_RESPONSE); }
/** * Get the current PortletRequest. * * @return The current PortletRequest. */ public static PortletRequest getRequest() { return (PortletRequest) getContext().get(REQUEST); }
/** * Gets the servlet context. * * @return the servlet context. */ public static ServletContext getServletContext() { return (ServletContext) ActionContext.getContext().get(SERVLET_CONTEXT); }
/** * Get the PortletConfig of the portlet that is executing. * * @return The PortletConfig of the executing portlet. */ public static PortletConfig getPortletConfig() { return (PortletConfig) getContext().get(PORTLET_CONFIG); }
/** * Get the current PortletResponse * * @return The current PortletResponse. */ public static PortletResponse getResponse() { return (PortletResponse) getContext().get(RESPONSE); }
/** * Get the phase that the portlet is executing in. * * @return {@link PortletActionConstants#RENDER_PHASE} in render phase, and * {@link PortletActionConstants#EVENT_PHASE} in the event phase. */ public static Integer getPhase() { return (Integer) getContext().get(PHASE); }
/** * Get the namespace to mode mappings. * * @return The map of the namespaces for each mode. */ public static Map getModeNamespaceMap() { return (Map)getContext().get(MODE_NAMESPACE_MAP); }
/** * Get the operationMode through request paramter, if <code>allowRequestParameterSwitch</code> * is 'true', else it simply returns 'NONE', meaning its neither in the 'STORE_MODE' nor * 'RETRIEVE_MODE'. * * @return String */ protected String getRequestOperationMode(ActionInvocation invocation) { String reqOperationMode = NONE; if (allowRequestParameterSwitch) { Map reqParams = (Map) invocation.getInvocationContext().get(ActionContext.PARAMETERS); boolean containsParameter = reqParams.containsKey(requestParameterSwitch); if (containsParameter) { String[] reqParamsArr = (String[]) reqParams.get(requestParameterSwitch); if (reqParamsArr != null && reqParamsArr.length > 0) { reqOperationMode = reqParamsArr[0]; } } } return reqOperationMode; }
/** * Get the RenderResponse. Can only be invoked in the render phase. * * @return The current RenderResponse. * @throws IllegalStateException If the method is invoked in the wrong phase. */ public static RenderResponse getRenderResponse() { if (!isRender()) { throw new IllegalStateException( "RenderResponse cannot be obtained in event phase"); } return (RenderResponse) getContext().get(RESPONSE); }
/** * Get the ActionRequest. Can only be invoked in the event phase. * * @return The current ActionRequest. * @throws IllegalStateException If the method is invoked in the wrong phase. */ public static ActionRequest getActionRequest() { if (!isEvent()) { throw new IllegalStateException( "ActionRequest cannot be obtained in render phase"); } return (ActionRequest) getContext().get(REQUEST); }
/** * Get the ActionRequest. Can only be invoked in the event phase. * * @return The current ActionRequest. * @throws IllegalStateException If the method is invoked in the wrong phase. */ public static ActionResponse getActionResponse() { if (!isEvent()) { throw new IllegalStateException( "ActionResponse cannot be obtained in render phase"); } return (ActionResponse) getContext().get(RESPONSE); }
/** * Get the RenderRequest. Can only be invoked in the render phase. * * @return The current RenderRequest. * @throws IllegalStateException If the method is invoked in the wrong phase. */ public static RenderRequest getRenderRequest() { if (!isRender()) { throw new IllegalStateException( "RenderRequest cannot be obtained in event phase"); } return (RenderRequest) getContext().get(REQUEST); }
/** * Invalidate this session if it is marked to be invalidated from previous request. * * @see com.opensymphony.xwork.interceptor.AroundInterceptor#before(com.opensymphony.xwork.ActionInvocation) */ protected void before(ActionInvocation invocation) throws Exception { SessionMap sessionMap = (SessionMap) invocation.getInvocationContext().get(ActionContext.SESSION); if (sessionMap.containsKey(key) && sessionMap.get(key).equals("true")) { if (LOG.isDebugEnabled()) LOG.debug("found marker in session indicating this is the 'next request', session should be invalidated"); sessionMap.invalidate(); LOG.info("session invalidated"); } } }
if (action instanceof ValidationAware) { Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION);