Search in sources :

Example 1 with FrontServletActionRedirectResult

use of org.entando.entando.aps.internalservlet.system.dispatcher.FrontServletActionRedirectResult in project entando-core by entando.

the class RedirectMessageInterceptor method after.

/**
 * If the result is a redirect then store error and messages in the session.
 * @param invocation
 * @param validationAware
 * @throws java.lang.Exception
 */
protected void after(ActionInvocation invocation, ValidationAware validationAware) throws Exception {
    Result result = invocation.getResult();
    if (result != null && (result instanceof ServletRedirectResult || result instanceof ServletActionRedirectResult || result instanceof FrontServletActionRedirectResult)) {
        HttpServletRequest request = (HttpServletRequest) invocation.getInvocationContext().get(ServletActionContext.HTTP_REQUEST);
        HttpSession session = request.getSession();
        Collection<String> actionErrors = validationAware.getActionErrors();
        if (actionErrors != null && actionErrors.size() > 0) {
            session.setAttribute(ACTION_ERRORS_KEY, actionErrors);
        }
        Collection<String> actionMessages = validationAware.getActionMessages();
        if (actionMessages != null && actionMessages.size() > 0) {
            session.setAttribute(ACTION_MESSAGES_KEY, actionMessages);
        }
        Map<String, List<String>> fieldErrors = validationAware.getFieldErrors();
        if (fieldErrors != null && fieldErrors.size() > 0) {
            session.setAttribute(FIELD_ERRORS_KEY, fieldErrors);
        }
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRedirectResult(org.apache.struts2.result.ServletRedirectResult) FrontServletActionRedirectResult(org.entando.entando.aps.internalservlet.system.dispatcher.FrontServletActionRedirectResult) HttpSession(javax.servlet.http.HttpSession) ServletActionRedirectResult(org.apache.struts2.result.ServletActionRedirectResult) FrontServletActionRedirectResult(org.entando.entando.aps.internalservlet.system.dispatcher.FrontServletActionRedirectResult) List(java.util.List) Result(com.opensymphony.xwork2.Result) ServletRedirectResult(org.apache.struts2.result.ServletRedirectResult) ServletActionRedirectResult(org.apache.struts2.result.ServletActionRedirectResult) FrontServletActionRedirectResult(org.entando.entando.aps.internalservlet.system.dispatcher.FrontServletActionRedirectResult)

Aggregations

Result (com.opensymphony.xwork2.Result)1 List (java.util.List)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpSession (javax.servlet.http.HttpSession)1 ServletActionRedirectResult (org.apache.struts2.result.ServletActionRedirectResult)1 ServletRedirectResult (org.apache.struts2.result.ServletRedirectResult)1 FrontServletActionRedirectResult (org.entando.entando.aps.internalservlet.system.dispatcher.FrontServletActionRedirectResult)1