Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.displaytag.filter
Class DisplayTagSpringInterceptor  view DisplayTagSpringInterceptor download DisplayTagSpringInterceptor.java

java.lang.Object
  extended byorg.displaytag.filter.DisplayTagSpringInterceptor
All Implemented Interfaces:
org.springframework.web.servlet.HandlerInterceptor

public class DisplayTagSpringInterceptor
extends java.lang.Object
implements org.springframework.web.servlet.HandlerInterceptor

Allow the author of an included JSP page to reset the content type to something else (like a binary stream), and then write the new info back as the exclusive response, clearing the buffers of all previously added content.

This interceptor allows TableTag users to perform exports from pages that are run as includes, such as from Struts or a jsp:include. If that is your intention, just add this interceptor to your spring dispatcher context xml and map it to the appropriate requests, using something like:

 <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
   <property name="interceptors">
     <list>
       <bean class="org.displaytag.filter.DisplayTagSpringInterceptor"/>
     </list>
   </property
 </bean>
 

By default the interceptor buffers all the export content before writing it out. You can set an optional parameter buffer to false to make the interceptor write directly to the output stream. This could be faster and uses less memory, but the content length will not be set.

  <bean class="org.displaytag.filter.DisplayTagSpringInterceptor">
      <property name="buffer"><value>false</value></property>
  </bean>
  

Version:
$Revision: 907 $ ($Author: fgiust $)

Field Summary
private  boolean buffer
          Force response buffering.
(package private) static org.apache.commons.logging.Log log
          Logger.
 
Constructor Summary
DisplayTagSpringInterceptor()
           
 
Method Summary
 void afterCompletion(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object obj, java.lang.Exception exception)
          Callback after completion of request processing, that is, after rendering the view.
 void postHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object obj, org.springframework.web.servlet.ModelAndView modelAndView)
          Intercept the execution of a handler.
 boolean preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler)
          Intercept the execution of a handler.
 void setBuffer(boolean bufferingEnabled)
          Sets the buffer state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

static org.apache.commons.logging.Log log
Logger.


buffer

private boolean buffer
Force response buffering. Enabled by default.

Constructor Detail

DisplayTagSpringInterceptor

public DisplayTagSpringInterceptor()
Method Detail

setBuffer

public void setBuffer(boolean bufferingEnabled)
Sets the buffer state.


preHandle

public boolean preHandle(javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response,
                         java.lang.Object handler)
                  throws java.lang.Exception
Description copied from interface: org.springframework.web.servlet.HandlerInterceptor
Intercept the execution of a handler. Called after HandlerMapping determined an appropriate handler object, but before HandlerAdapter invokes the handler.

DispatcherServlet processes a handler in an execution chain, consisting of any number of interceptors, with the handler itself at the end. With this method, each interceptor can decide to abort the execution chain, typically sending a HTTP error or writing a custom response.

Specified by:
preHandle in interface org.springframework.web.servlet.HandlerInterceptor

postHandle

public void postHandle(javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response,
                       java.lang.Object obj,
                       org.springframework.web.servlet.ModelAndView modelAndView)
                throws java.lang.Exception
Description copied from interface: org.springframework.web.servlet.HandlerInterceptor
Intercept the execution of a handler. Called after HandlerAdapter actually invoked the handler, but before the DispatcherServlet renders the view. Can expose additional model objects to the view via the given ModelAndView.

DispatcherServlet processes a handler in an execution chain, consisting of any number of interceptors, with the handler itself at the end. With this method, each interceptor can post-process an execution, getting applied in inverse order of the execution chain.

Specified by:
postHandle in interface org.springframework.web.servlet.HandlerInterceptor

afterCompletion

public void afterCompletion(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response,
                            java.lang.Object obj,
                            java.lang.Exception exception)
                     throws java.lang.Exception
Description copied from interface: org.springframework.web.servlet.HandlerInterceptor
Callback after completion of request processing, that is, after rendering the view. Will be called on any outcome of handler execution, thus allows for proper resource cleanup.

Note: Will only be called if this interceptor's preHandle method has successfully completed and returned true!

Specified by:
afterCompletion in interface org.springframework.web.servlet.HandlerInterceptor