Save This Page
Home » webwork-2.2.7 » com.opensymphony.webwork.dispatcher » [javadoc | source]
com.opensymphony.webwork.dispatcher
public class: FilterDispatcher [javadoc | source]
java.lang.Object
   com.opensymphony.webwork.dispatcher.FilterDispatcher

All Implemented Interfaces:
    Filter, WebWorkStatics

Direct Known Subclasses:
    FilterDispatcherCompatWeblogic61, PicoFilterDispatcher

Master filter for WebWork that handles four distinct responsibilities:

IMPORTANT: this filter must be mapped to all requests. Unless you know exactly what you are doing, always map to this URL pattern: /*

Executing actions

This filter executes actions by consulting the ActionMapper and determining if the requested URL should invoke an action. If the mapper indicates it should, the rest of the filter chain is stopped and the action is invoked. This is important, as it means that filters like the SiteMesh filter must be placed before this filter or they will not be able to decorate the output of actions.

Cleaning up the ActionContext

This filter will also automatically clean up the ActionContext for you, ensuring that no memory leaks take place. However, this can sometimes cause problems integrating with other products like SiteMesh. See ActionContextCleanUp for more information on how to deal with this.

Serving static content

This filter also serves common static content needed when using various parts of WebWork, such as JavaScript files, CSS files, etc. It works by looking for requests to /webwork/*, and then mapping the value after "/webwork/" to common packages in WebWork and, optionally, in your class path. By default, the following packages are automatically searched:

This means that you can simply request /webwork/xhtml/styles.css and the XHTML UI theme's default stylesheet will be returned. Likewise, many of the AJAX UI components require various JavaScript files, which are found in the com.opensymphony.webwork.static package. If you wish to add additional packages to be searched, you can add a comma separated (space, tab and new line will do as well) list in the filter init parameter named "packages". Be careful, however, to expose any packages that may have sensitive information, such as properties file with database access credentials.

Kicking off XWork's IoC for the request lifecycle

This filter also kicks off the XWork IoC request scope, provided that you are using XWork's IoC. All you have to do to get started with XWork's IoC is add a components.xml file to WEB-INF/classes and properly set up the com.opensymphony.webwork.lifecycle.LifecycleListener in web.xml. See the IoC docs for more information.

Field Summary
protected  FilterConfig filterConfig     
protected  String[] pathPrefixes     
Method from com.opensymphony.webwork.dispatcher.FilterDispatcher Summary:
afterActionInvocation,   beforeActionInvocation,   checkUrl,   copy,   createComponentManager,   destroy,   doFilter,   findInputStream,   findStaticResource,   getFilterConfig,   getServletContext,   init,   parse,   setupContainer
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.opensymphony.webwork.dispatcher.FilterDispatcher Detail:
 protected  void afterActionInvocation(HttpServletRequest request,
    Object o,
    Object o1) 
 protected Object beforeActionInvocation(HttpServletRequest request,
    ServletContext servletContext) 
 protected boolean checkUrl(URL url,
    String rawResourcePath) 
    handle .. chars here and other URL hacks
 protected  void copy(InputStream input,
    OutputStream output) throws IOException 
 protected DefaultComponentManager createComponentManager() 
    Returns a new DefaultComponentManager instance. This method is useful for developers wishing to subclass this class and provide a different implementation of DefaultComponentManager.
 public  void destroy() 
 public  void doFilter(ServletRequest req,
    ServletResponse res,
    FilterChain chain) throws IOException, ServletException 
 protected InputStream findInputStream(String name,
    String packagePrefix) throws IOException 
 protected  void findStaticResource(String name,
    HttpServletResponse response) throws IOException 
 public FilterConfig getFilterConfig() 
 protected ServletContext getServletContext(HttpSession session) 
    Servlet 2.3 specifies that the servlet context can be retrieved from the session. Unfortunately, some versions of WebLogic can only retrieve the servlet context from the filter config. Hence, this method enables subclasses to retrieve the servlet context from other sources.
 public  void init(FilterConfig filterConfig) throws ServletException 
 protected String[] parse(String packages) 
 protected  void setupContainer(HttpServletRequest request)