View Javadoc

1   /*
2    * $Id: ActionForward.java 421119 2006-07-12 04:49:11Z wsmoak $
3    *
4    * Copyright 2000-2004 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts.action;
19  
20  import org.apache.struts.config.ForwardConfig;
21  
22  /***
23   * <p>An <strong>ActionForward</strong> represents a destination to which the
24   * controller, RequestProcessor, might be directed to perform a
25   * RequestDispatcher.forward or HttpServletResponse.sendRedirect to, as a
26   * result of processing activities of an Action class. Instances of this class
27   * may be created dynamically as necessary, or configured in association with
28   * an ActionMapping instance for named lookup of potentially multiple
29   * destinations for a particular mapping instance.</p>
30   *
31   * <p>An ActionForward has the following minimal set of properties. Additional
32   * properties can be provided as needed by subclassses.</p>
33   *
34   * <ul>
35   *
36   * <li><strong>contextRelative</strong> - Should the path value be interpreted
37   * as context-relative (instead of module-relative, if it starts with a '/'
38   * character? [false]</li>
39   *
40   * <li><strong>name</strong> - Logical name by which this instance may be
41   * looked up in relationship to a particular ActionMapping. </li>
42   *
43   * <li><strong>path</strong> - Module-relative or context-relative URI to
44   * which control should be forwarded, or an absolute or relative URI to which
45   * control should be redirected.</li>
46   *
47   * <li><strong>redirect</strong> - Set to true if the controller servlet
48   * should call HttpServletResponse.sendRedirect() on the associated path;
49   * otherwise false. [false]</li>
50   *
51   * </ul>
52   *
53   * <p>Since Struts 1.1 this class extends ForwardConfig and inherits the
54   * contextRelative property.
55   *
56   * <p><strong>NOTE</strong> - This class would have been deprecated and
57   * replaced by org.apache.struts.config.ForwardConfig except for the fact that
58   * it is part of the public API that existing applications are using.</p>
59   *
60   * @version $Rev: 421119 $ $Date: 2005-08-14 17:24:39 -0400 (Sun, 14 Aug 2005)
61   *          $
62   */
63  public class ActionForward extends ForwardConfig {
64      /***
65       * <p>Construct a new instance with default values.</p>
66       */
67      public ActionForward() {
68          this(null, false);
69      }
70  
71      /***
72       * <p>Construct a new instance with the specified path.</p>
73       *
74       * @param path Path for this instance
75       */
76      public ActionForward(String path) {
77          this(path, false);
78      }
79  
80      /***
81       * <p>Construct a new instance with the specified <code>path</code> and
82       * <code>redirect</code> flag.</p>
83       *
84       * @param path     Path for this instance
85       * @param redirect Redirect flag for this instance
86       */
87      public ActionForward(String path, boolean redirect) {
88          super();
89          setName(null);
90          setPath(path);
91          setRedirect(redirect);
92      }
93  
94      /***
95       * <p>Construct a new instance with the specified <code>name</code>,
96       * <code>path</code> and <code>redirect</code> flag.</p>
97       *
98       * @param name     Name of this instance
99       * @param path     Path for this instance
100      * @param redirect Redirect flag for this instance
101      */
102     public ActionForward(String name, String path, boolean redirect) {
103         super();
104         setName(name);
105         setPath(path);
106         setRedirect(redirect);
107     }
108 
109     /***
110      * <p>Construct a new instance with the specified values.</p>
111      *
112      * @param name     Name of this forward
113      * @param path     Path to which control should be forwarded or
114      *                 redirected
115      * @param redirect Should we do a redirect?
116      * @param module   Module prefix, if any
117      */
118     public ActionForward(String name, String path, boolean redirect,
119         String module) {
120         super();
121         setName(name);
122         setPath(path);
123         setRedirect(redirect);
124         setModule(module);
125     }
126 
127     /***
128      * <p>Construct a new instance based on the values of another
129      * ActionForward.</p>
130      *
131      * @param copyMe An ActionForward instance to copy
132      * @since Struts 1.2.1
133      */
134     public ActionForward(ActionForward copyMe) {
135         this(copyMe.getName(), copyMe.getPath(), copyMe.getRedirect(),
136             copyMe.getModule());
137     }
138 }