Igor Vaynberg wrote:
can you not roll your own simple filter? you can pull the webapp from
the servletcontext

-igor

Thanks for the suggestion. It works perfectly.

Here is the code for those that are interested.

import org.apache.wicket.Application;
import org.apache.wicket.protocol.http.WebApplication;

import javax.servlet.*;
import java.io.IOException;

/**
* Filter that sets the wicket application, just like [EMAIL PROTECTED] org.apache.wicket.protocol.http.WicketFilter}
* would do.
*
* <p>This implementation assumes that it is placed in a filter chain, <i>after</i> WicketFilter,
* for URLs that are not handled by the WicketFilter.
*
* <p>The filter name of the wicket filter is retrieved from the init parameter wicketFilterName.
*
* @author Erik van Oosten
*/
public class WicketApplicationFilter implements Filter {

   private WebApplication webApplication;

   public void init(FilterConfig filterConfig) throws ServletException {
// Get instance of the Wicket application, it is set by the Wicket filter. String contextKey = "wicket:" + filterConfig.getInitParameter("wicketFilterName"); webApplication = (WebApplication) filterConfig.getServletContext().getAttribute(contextKey);

       if (webApplication == null) {
throw new ServletException("Could not find the Wicket application, please make " + "sure filter WicketApplicationFilter is embedded in Wicket's filter");
       }
   }

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
       try {
           // Set the webapplication for this thread
           Application.set(webApplication);

           chain.doFilter(request, response);

       } finally {
           // always unset the application thread local
           Application.unset();
       }
   }

   public void destroy() {
       webApplication = null;
   }
}


Regards,
   Erik.


--
Erik van Oosten
http://day-to-day-stuff.blogspot.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to