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

Quick Search    Search Deep

Source code: org/infohazard/maverick/view/RedirectViewFactory.java


1   /*
2    * $Id: RedirectViewFactory.java,v 1.4 2002/06/06 12:23:56 lhoriman Exp $
3    * $Source: /cvsroot/mav/maverick/src/java/org/infohazard/maverick/view/RedirectViewFactory.java,v $
4    */
5   
6   package org.infohazard.maverick.view;
7   
8   import org.infohazard.maverick.flow.*;
9   import org.infohazard.maverick.util.XML;
10  import javax.servlet.ServletConfig;
11  import org.jdom.Element;
12  
13  
14  /**
15   * <p>Creates views which result in HTTP redirects.</p>
16   *
17   * <p>Views will handle the model in the following way:</p>
18   *
19   * <ul>
20   *   <li>
21   * If the model is a String, that is used as the base URL
22   * and the path attribute is ignored.
23   *   </li>
24   *   <li>
25   * If the model is a Map, the key/value pairs are converted
26   * into parameters for the target URL.  This behavior is
27   * deprecated; you should use ControllerContext.setParam()
28   * instead.
29   *   </li>
30   * </ul>
31   *
32   * <p>Params set on the ControllerContext will become
33   * query parameters.</p>
34   *
35   * <p>Redirect views cannot have transforms and have no
36   * attributes other than "path".</p>
37   */
38  public class RedirectViewFactory implements ViewFactory
39  {
40    /**
41     */
42    public void init(Element factoryNode, ServletConfig servletCfg) throws ConfigException
43    {
44      // Nothing to do.
45    }
46  
47    /**
48     */
49    public View createView(Element viewNode) throws ConfigException
50    {
51      String path = XML.getValue(viewNode, "path");
52  
53      // If it doesn't exist, the path must be set by the model().
54      if (path == null)
55        path = "";
56  
57      return new RedirectView(path);
58    }
59  }