Search code examples
springspring-mvcportletjsr286

Spring Portal MVC Clear Action Exception going to Render Phase


I would like to know whether or not it is possible to clear an exception out of the request when trying to hit the Render Phase after the Action Phase has thrown the exception.

If you look at this code snippet from the doRenderService method of DispatchPortlet.class (a Spring provided class):

PortletSession session = request.getPortletSession(false);
if (session != null) {
    if (request.getParameter(ACTION_EXCEPTION_RENDER_PARAMETER) != null) {
        Exception ex = (Exception)        
        session.getAttribute(ACTION_EXCEPTION_SESSION_ATTRIBUTE);
        if (ex != null) {
            logger.debug("Render phase found exception caught during action phase - rethrowing it");
            throw ex;
        }
     }
     else {
         session.removeAttribute(ACTION_EXCEPTION_SESSION_ATTRIBUTE);
     }
}

You can see here that an exception gets put into the parameter map and there doesn't seem to be any way to clear it out.

What I would like to do is originally catch the Exception (what I am successfully doing), display an "Error Page" (what I am successfully doing), then display a button on that Error Page that allows the user to bring up the "Render Phase" page again so that he/she may be able to try their Action, again.

I've tried to create a filter, interceptor, new controller to clear the parameter, but it seems that the ParameterMap is an UnmodifiableCollection.

Any thoughts?


Solution

  • I actually was able to figure this out by doing the following in a render-phase filter:

    session.setAttribute(ACTION_EXCEPTION_SESSION_ATTRIBUTE, null)