1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.struts.scripting;
20
21
22 import org.apache.struts.action.ActionForm;
23 import org.apache.struts.action.ActionForward;
24 import org.apache.struts.action.ActionMapping;
25 import org.apache.struts.util.MessageResources;
26
27
28 /***
29 * Holds Struts objects.
30 */
31 public class StrutsInfo {
32
33 /*** Forward name. */
34 private String forwardName = null;
35
36 /*** Forward object. */
37 private ActionForward forward = null;
38
39 /*** ActionForm for this request. */
40 private ActionForm form = null;
41
42 /*** ActionMapping for this request. */
43 private ActionMapping mapping = null;
44
45 /*** ScriptAction instance for this request. */
46 private ScriptAction action = null;
47
48 /*** The message resources for this request. */
49 private MessageResources res = null;
50
51 /***
52 * Constructor.
53 *
54 * @param action The action instance
55 * @param mapping The action mapping
56 * @param form The action form
57 * @param res The message resources for the current locale
58 */
59 public StrutsInfo(ScriptAction action, ActionMapping mapping,
60 ActionForm form, MessageResources res) {
61 this.action = action;
62 this.mapping = mapping;
63 this.form = form;
64 this.res = res;
65 }
66
67 /***
68 * Sets the forward name.
69 *
70 * @param f The forward name
71 */
72 public void setForwardName(String f) {
73 forwardName = f;
74 }
75
76 /***
77 * Gets the forward object. If none is set, it tries to find the set
78 * forward name.
79 *
80 * @return The action forward
81 */
82 public ActionForward getForward() {
83 if (forward == null) {
84 if (forwardName != null) {
85 return mapping.findForward(forwardName);
86 }
87 }
88 return forward;
89 }
90
91 /***
92 * Sets the action forward object.
93 *
94 * @param f The action forward
95 */
96 public void setForward(ActionForward f) {
97 forward = f;
98 }
99
100 /***
101 * Sets the action form.
102 *
103 * @param form The action form
104 */
105 public void setForm(ActionForm form) {
106 this.form = form;
107 }
108
109 /***
110 * Sets the action mapping.
111 *
112 * @param mapping The action mapping
113 */
114 public void setMapping(ActionMapping mapping) {
115 this.mapping = mapping;
116 }
117
118 /***
119 * Sets the action instance.
120 *
121 * @param action The Struts action
122 */
123 public void setAction(ScriptAction action) {
124 this.action = action;
125 }
126
127 /***
128 * Sets the message resources.
129 *
130 * @param res The message resources
131 */
132 public void setMessages(MessageResources res) {
133 this.res = res;
134 }
135
136 /***
137 * Gets the action form.
138 *
139 * @return The action form
140 */
141 public ActionForm getForm() {
142 return form;
143 }
144
145 /***
146 * Gets the action mapping.
147 *
148 * @return The action mapping
149 */
150 public ActionMapping getMapping() {
151 return mapping;
152 }
153
154 /***
155 * Gets the action instance.
156 *
157 * @return The Struts action
158 */
159 public ScriptAction getAction() {
160 return action;
161 }
162
163 /***
164 * Gets the message resources.
165 *
166 * @return The message resources
167 */
168 public MessageResources getMessages() {
169 return res;
170 }
171 }
172