public Action extractAction(ActionInvocation invocation) { return invocation.getAction(); }
/** * Returns the locale used for the {@link Configuration#getTemplate(String, Locale)} call. The base implementation * simply returns the locale setting of the action (assuming the action implements {@link LocaleProvider}) or, if * the action does not the configuration's locale is returned. Override this method to provide different behaviour, */ protected Locale getLocale(ActionInvocation invocation, Configuration configuration) { if (invocation.getAction() instanceof LocaleProvider) { return ((LocaleProvider) invocation.getAction()).getLocale(); } else { return configuration.getLocale(); } }
/** * Returns the locale used for the {@link Configuration#getTemplate(String, Locale)} call. The base implementation * simply returns the locale setting of the action (assuming the action implements {@link LocaleProvider}) or, if * the action does not the configuration's locale is returned. Override this method to provide different behaviour, */ protected Locale deduceLocale() { if (invocation.getAction() instanceof LocaleProvider) { return ((LocaleProvider) invocation.getAction()).getLocale(); } else { return configuration.getLocale(); } }
/** * Attempt to deduce the Locale, based on <code>invocation</code> and * Freemarker's <code>configuration</code>. * * @param invocation * @param configuration * @return */ protected Locale deduceLocale(ActionInvocation invocation, Configuration configuration) { if (invocation.getAction() instanceof LocaleProvider) { return ((LocaleProvider) invocation.getAction()).getLocale(); } else { return configuration.getLocale(); } }
public BackgroundProcess(String threadName, final ActionInvocation invocation, int threadPriority) { this.invocation = invocation; this.action = invocation.getAction(); try { final Thread t = new Thread(new Runnable() { public void run() { try { beforeInvocation(); result = invocation.invokeActionOnly(); afterInvocation(); } catch (Exception e) { exception = e; } done = true; } }); t.setName(threadName); t.setPriority(threadPriority); t.start(); } catch (Exception e) { exception = e; } }
public void beforeResult(ActionInvocation invocation, String resultCode) { Map sessionMap = ActionContext.getContext().getSession(); Object action = invocation.getAction(); if (LOG.isDebugEnabled()) LOG.debug("inserting action ["+action+"] into session with key ["+key+"]"); sessionMap.put(key, action); } });
public static Map getStandardContext(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) { HashMap map = new HashMap(); map.put(REQUEST, req); map.put(REQUEST2, req); map.put(RESPONSE, res); map.put(RESPONSE2, res); map.put(SESSION, req.getSession(false)); map.put(BASE, req.getContextPath()); map.put(STACK, stack); map.put(OGNL, OgnlTool.getInstance()); map.put(WEBWORK, new WebWorkUtil(stack, req, res)); ActionInvocation invocation = (ActionInvocation) stack.getContext().get(ActionContext.ACTION_INVOCATION); if (invocation != null) { map.put(ACTION, invocation.getAction()); } return map; }
private static Action getCurrentAction() { ActionContext ctx = ActionContext.getContext(); if ( ctx != null ) { ActionInvocation ai = ctx.getActionInvocation(); if ( ai != null ) return ai.getAction(); } return null; }
/** * A flash result, that save the current action into the http session before * invoking <code>super.doExecute(...)</code>. * * @see com.opensymphony.webwork.dispatcher.ServletRedirectResult#doExecute(java.lang.String, com.opensymphony.xwork.ActionInvocation) */ protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { // before we redirect, let's save the state in to the session Object action = invocation.getAction(); Map session = invocation.getInvocationContext().getSession(); session.put(FlashInterceptor.DEFAULT_KEY, action); super.doExecute(finalLocation, invocation); }
protected void before(ActionInvocation invocation) throws Exception { Map session = invocation.getInvocationContext().getSession(); ApplicationContext applicationContext = (ApplicationContext) session.get(ApplicationContextSessionListener.APP_CONTEXT_SESSION_KEY); AutowireCapableBeanFactory factory = findAutoWiringBeanFactory(applicationContext); factory.autowireBeanProperties(invocation.getAction(),autowireStrategy.intValue(),false); }
injectIntoCookiesAwareAction(invocation.getAction(), cookiesMap);
STORE_MODE.equalsIgnoreCase(operationMode)) { Object action = invocation.getAction(); if (action instanceof ValidationAware) {
/** * Determines what to do if an invalida token is provided. If the action implements {@link ValidationAware} * * @param invocation the action invocation where the invalid token failed * @return the return code to indicate should be processed * @throws Exception when any unexpected error occurs. */ protected String handleInvalidToken(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); String errorMessage = LocalizedTextUtil.findText(this.getClass(), "webwork.messages.invalid.token", invocation.getInvocationContext().getLocale(), "The form has already been processed or no token was supplied, please try again.", new Object[0]); if (action instanceof ValidationAware) { ((ValidationAware) action).addActionError(errorMessage); } else { log.warn(errorMessage); } return INVALID_TOKEN_CODE; }
protected TemplateModel createModel(ObjectWrapper wrapper, ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws TemplateModelException { OgnlValueStack stack = ServletActionContext.getContext().getValueStack(); Object action = null; if (ServletActionContext.getContext().getActionInvocation() != null) { action = ServletActionContext.getContext().getActionInvocation().getAction(); } TemplateModel model = FreemarkerManager.getInstance().buildTemplateModel(stack, action, servletContext, request, response, wrapper); return model; }
/** * Build the instance of the ScopesHashModel, including JspTagLib support * <p/> * Objects added to the model are * <p/> * <ul> * <li>Application - servlet context attributes hash model * <li>JspTaglibs - jsp tag lib factory model * <li>Request - request attributes hash model * <li>Session - session attributes hash model * <li>req - the HttpServletRequst object for direct access * <li>res - the HttpServletResponse object for direct access * <li>stack - the OgnLValueStack instance for direct access * <li>ognl - the instance of the OgnlTool * <li>action - the action itself * <li>exception - optional : the JSP or Servlet exception as per the servlet spec (for JSP Exception pages) * <li>webwork - instance of the WebWorkUtil class * </ul> */ protected TemplateModel createModel() throws TemplateModelException { ServletContext servletContext = ServletActionContext.getServletContext(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); OgnlValueStack stack = ServletActionContext.getContext().getValueStack(); Object action = null; if(invocation!= null ) action = invocation.getAction(); //Added for NullPointException return FreemarkerManager.getInstance().buildTemplateModel(stack, action, servletContext, request, response, wrapper); }
/** * Build the instance of the ScopesHashModel, including JspTagLib support * <p/>Objects added to the model are <p/> * <ul> * <li>Application - servlet context attributes hash model * <li>JspTaglibs - jsp tag lib factory model * <li>Request - request attributes hash model * <li>Session - session attributes hash model * <li>req - the HttpServletRequst object for direct access * <li>res - the HttpServletResponse object for direct access * <li>stack - the OgnLValueStack instance for direct access * <li>ognl - the instance of the OgnlTool * <li>action - the action itself * <li>exception - optional : the JSP or Servlet exception as per the * servlet spec (for JSP Exception pages) * <li>webwork - instance of the WebWorkUtil class * </ul> */ protected TemplateModel createModel() throws TemplateModelException { ServletContext servletContext = ServletActionContext .getServletContext(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); OgnlValueStack stack = ServletActionContext.getContext() .getValueStack(); return FreemarkerManager.getInstance().buildTemplateModel(stack, invocation.getAction(), servletContext, request, response, wrapper); }
/** * */ protected AjaxResult doExecute(ActionDefinition actionDefinition, Map<String, String> params, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) throws ServletException { FakeHttpServletResponse actionResponse = new FakeHttpServletResponse(); if (null != actionProcessor) { actionProcessor.preProcess(request, response, actionResponse, params); } wwDispatcher.prepare(request, actionResponse); ActionInvocation invocation = invokeAction(wwDispatcher, request, actionResponse, servletContext, actionDefinition, params); AjaxResult result; if (actionDefinition.isExecuteResult()) { // HINT: we have output string result = getTextResult(actionResponse); } else { result = new DefaultAjaxDataResult(invocation.getAction()); } if (null != actionProcessor) { actionProcessor.postProcess(request, response, actionResponse, result); } return result; }
/** * Create a Freemarker's Model through {@link FreemarkerManager#buildTemplateModel(OgnlValueStack, Object, ServletContext, HttpServletRequest, HttpServletResponse, ObjectWrapper)}. * * @return * @throws TemplateException */ protected SimpleHash createModel() throws TemplateException { FreemarkerManager freemarkerManager = FreemarkerManager.getInstance(); ActionInvocation invocation = ActionContext.getContext().getActionInvocation(); ServletContext servletContext = JspSupportServlet.jspSupportServlet.getServletContext(); OgnlValueStack stack = ActionContext.getContext().getValueStack(); ObjectWrapper wrapper = freemarkerManager.getConfiguration(servletContext).getObjectWrapper(); Object action = null; if(invocation!= null ) action = invocation.getAction(); //Added for NullPointException return freemarkerManager.buildTemplateModel(stack, action, servletContext, request, response, wrapper); } }