Source code: org/apache/struts/action/ActionForward.java
1 /*
2 * $Id: ActionForward.java 54929 2004-10-16 16:38:42Z germuska $
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
19
20 package org.apache.struts.action;
21
22
23 import org.apache.struts.config.ForwardConfig;
24
25
26 /**
27 * <p>An <strong>ActionForward</strong> represents a destination to which the
28 * controller, <code>RequestProcessor</code>, might be directed to
29 * perform a <code>RequestDispatcher.forward</code> or
30 * <code>HttpServletResponse.sendRedirect</code> to, as a result of
31 * processing activities of an <code>Action</code> class. Instances of this
32 * class may be created dynamically as necessary, or configured in association
33 * with an <code>ActionMapping</code> instance for named lookup of potentially
34 * multiple destinations for a particular mapping instance.</p>
35 *
36 * <p>An <code>ActionForward</code> has the following minimal set of properties.
37 * Additional properties can be provided as needed by subclassses.</p>
38 * <ul>
39 * <li><strong>contextRelative</strong> - Should the <code>path</code>
40 * value be interpreted as context-relative (instead of
41 * module-relative, if it starts with a '/' character? [false]</li>
42 * <li><strong>name</strong> - Logical name by which this instance may be
43 * looked up in relationship to a particular <code>ActionMapping</code>.
44 * </li>
45 * <li><strong>path</strong> - Module-relative or context-relative URI to
46 * which control should be forwarded, or an absolute or relative URI to
47 * which control should be redirected.</li>
48 * <li><strong>redirect</strong> - Set to <code>true</code> if the controller
49 * servlet should call <code>HttpServletResponse.sendRedirect()</code>
50 * on the associated path; otherwise <code>false</code>. [false]</li>
51 * </ul>
52 *
53 * <p>Since Struts 1.1 this class extends <code>ForwardConfig</code>
54 * and inherits the <code>contextRelative</code> property.
55 *
56 * <p><strong>NOTE</strong> - This class would have been deprecated and
57 * replaced by <code>org.apache.struts.config.ForwardConfig</code> except
58 * for the fact that it is part of the public API that existing applications
59 * are using.</p>
60 *
61 * @version $Rev: 54929 $ $Date: 2004-10-16 09:38:42 -0700 (Sat, 16 Oct 2004) $
62 */
63
64 public class ActionForward extends ForwardConfig {
65
66
67 /**
68 * <p>Construct a new instance with default values.</p>
69 */
70 public ActionForward() {
71
72 this(null, false);
73
74 }
75
76
77 /**
78 * <p>Construct a new instance with the specified path.</p>
79 *
80 * @param path Path for this instance
81 */
82 public ActionForward(String path) {
83
84 this(path, false);
85
86 }
87
88
89 /**
90 * <p>Construct a new instance with the specified
91 * <code>path</code> and <code>redirect</code> flag.</p>
92 *
93 * @param path Path for this instance
94 * @param redirect Redirect flag for this instance
95 */
96 public ActionForward(String path, boolean redirect) {
97
98 super();
99 setName(null);
100 setPath(path);
101 setRedirect(redirect);
102
103 }
104
105
106 /**
107 * <p>Construct a new instance with the specified <code>name</code>,
108 * <code>path</code> and <code>redirect</code> flag.</p>
109 *
110 * @param name Name of this instance
111 * @param path Path for this instance
112 * @param redirect Redirect flag for this instance
113 */
114 public ActionForward(String name, String path, boolean redirect) {
115
116 super();
117 setName(name);
118 setPath(path);
119 setRedirect(redirect);
120
121 }
122
123
124 /**
125 * <p>Construct a new instance with the specified values.</p>
126 *
127 * @param name Name of this instance
128 * @param path Path for this instance
129 * @param redirect Redirect flag for this instance
130 * @param contextRelative Context relative flag for this instance
131 * @deprecated Use module rather than contextRelative
132 */
133 public ActionForward(String name, String path, boolean redirect,
134 boolean contextRelative) {
135
136 super();
137 setName(name);
138 setPath(path);
139 setRedirect(redirect);
140 setContextRelative(contextRelative);
141
142 }
143
144
145 /**
146 * Construct a new instance with the specified values.
147 *
148 * @param name Name of this forward
149 * @param path Path to which control should be forwarded or redirected
150 * @param redirect Should we do a redirect?
151 * @param module Module prefix, if any
152 */
153 public ActionForward(String name, String path, boolean redirect,
154 String module) {
155
156 super();
157 setName(name);
158 setPath(path);
159 setRedirect(redirect);
160 setModule(module);
161
162 }
163
164
165 /**
166 * <p>Construct a new instance based on the values of another ActionForward.</p>
167 *
168 * @param copyMe An ActionForward instance to copy
169 * @since Struts 1.2.1
170 */
171 public ActionForward(ActionForward copyMe) {
172 this(copyMe.getName(),copyMe.getPath(),copyMe.getRedirect(),copyMe.getModule());
173 setContextRelative(copyMe.getContextRelative());
174 }
175
176 }