org.riotfamily.website.interceptor
Class PushUpInterceptor

java.lang.Object
  extended by org.springframework.web.servlet.handler.HandlerInterceptorAdapter
      extended by org.riotfamily.website.interceptor.PushUpInterceptor
All Implemented Interfaces:
HandlerInterceptor

public class PushUpInterceptor
extends HandlerInterceptorAdapter

HandlerInterceptor that allows an included controller to handle the request before any other controller is executed. This is useful if an included controller needs to send a redirect, which would not work under normal circumstances, since the response would have already been committed.

The interceptor looks for a special request parameter which contains the URI of the controller that should handle the request in the fist place. If such a parameter is present, the interceptor will use a RequestDispatcher to forward the request to that URI. For this forward the response is replaced by a wrapper that captures the output and checks whether a redirect or error has been sent. If yes, the interceptor prevents the execution of the actual handler. Otherwise the execution continues and the captured output is rendered when the controller is requested for the second time.


Field Summary
static String INCLUDE_URI_PARAM
           
 
Constructor Summary
PushUpInterceptor()
           
 
Method Summary
protected  boolean handleFirstInclude(Object handler, HttpServletRequest request)
           
protected  boolean handleSubsequentInclude(Object handler, Object firstHandler, HttpServletRequest request, HttpServletResponse response)
           
protected  boolean handleUnknown(HttpServletRequest request, HttpServletResponse response)
           
 boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
           
 
Methods inherited from class org.springframework.web.servlet.handler.HandlerInterceptorAdapter
afterCompletion, postHandle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INCLUDE_URI_PARAM

public static final String INCLUDE_URI_PARAM
See Also:
Constant Field Values
Constructor Detail

PushUpInterceptor

public PushUpInterceptor()
Method Detail

preHandle

public boolean preHandle(HttpServletRequest request,
                         HttpServletResponse response,
                         Object handler)
                  throws Exception
Specified by:
preHandle in interface HandlerInterceptor
Overrides:
preHandle in class HandlerInterceptorAdapter
Throws:
Exception

handleUnknown

protected boolean handleUnknown(HttpServletRequest request,
                                HttpServletResponse response)
                         throws Exception
Throws:
Exception

handleFirstInclude

protected boolean handleFirstInclude(Object handler,
                                     HttpServletRequest request)

handleSubsequentInclude

protected boolean handleSubsequentInclude(Object handler,
                                          Object firstHandler,
                                          HttpServletRequest request,
                                          HttpServletResponse response)
                                   throws IOException
Throws:
IOException