Class ActionFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    public class ActionFilter
    extends Object
    implements javax.servlet.Filter
    A filter that dispatches requests to the right action, depending on the button that was pressed in the editing form. This is needed since the browser cannot send the form data to different URLs depending on the button pressed, and an XHTML form has only one target URL. In previous versions of XWiki this was accomplished using javascript code, with a fall-back on a pseudo-dispatcher inside the PreviewAction, which was on obvious case of bad code design.

    The filter dispatches requests based on the presence of a request parameter starting with action_ followed by the name of the struts action that should actually process the request. For example, the button that does Save and Continue looks like:

     <input type="submit" name="action_saveandcontinue" value="..."/>
     
    As a result, when clicking the button, the request is not sent to the form's target (preview), but is actually forwarded internally to /bin/saveandcontinue/The/Document.
    Since:
    1.8M1
    Version:
    $Id: 566bc0e5320ecbc01b1ebae9112e70c50e1e4117 $
    • Constructor Detail

      • ActionFilter

        public ActionFilter()
    • Method Detail

      • init

        public void init​(javax.servlet.FilterConfig filterConfig)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Filter
        Throws:
        javax.servlet.ServletException
      • doFilter

        public void doFilter​(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain chain)
                      throws IOException,
                             javax.servlet.ServletException
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        IOException
        javax.servlet.ServletException
      • destroy

        public void destroy()
        Specified by:
        destroy in interface javax.servlet.Filter