1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2;
23
24 import java.util.*;
25
26 import org.apache.struts2.views.jsp.ui.User;
27
28 import com.opensymphony.xwork2.Action;
29 import com.opensymphony.xwork2.ActionSupport;
30 import com.opensymphony.xwork2.util.ValueStack;
31
32
33 /***
34 */
35 public class TestAction extends ActionSupport {
36
37 private static final long serialVersionUID = -8891365561914451494L;
38
39 private Collection collection;
40 private Collection collection2;
41 private Map map;
42 private String foo;
43 private Integer fooInt;
44 private String result;
45 private User user;
46 private String[] array;
47 private String[][] list;
48 private List list2;
49 private List list3;
50 private SomeEnum status = SomeEnum.COMPLETED;
51
52 private final Map<String, String> texts = new HashMap<String, String>();
53
54 /***
55 * Define a text resource within this action that will be returned by the getText methods
56 * here before delegating to the default TextProvider
57 *
58 * call
59 * @param key
60 * @param value
61 */
62 public void setText(String key, String value) {
63 this.texts.put(key, value);
64 }
65
66 /*** Returns the test value if defined otherwise delegates to the default TextProvider */
67 public String getText(String key) {
68 if (this.texts.containsKey(key)) {
69 return this.texts.get(key);
70 }
71 return super.getText(key);
72 }
73
74 /*** This is the method invoked by the {@link org.apache.struts2.util.TextProviderHelper}.
75 * Returns the test value if defined otherwise delegates to the default TextProvider */
76 public String getText(String key, String defaultValue, List args, ValueStack stack) {
77 if (this.texts.containsKey(key)) {
78 return this.texts.get(key);
79 } else {
80 return super.getText(key, defaultValue, args, stack);
81 }
82 }
83
84 public Collection getCollection() {
85 return collection;
86 }
87
88 public void setCollection(Collection collection) {
89 this.collection = collection;
90 }
91
92 public Map getMap() {
93 return map;
94 }
95
96 public void setMap(Map map) {
97 this.map = map;
98 }
99
100 public String getFoo() {
101 return foo;
102 }
103
104 public void setFoo(String foo) {
105 this.foo = foo;
106 }
107
108 public String getResult() {
109 return result;
110 }
111
112 public void setResult(String result) {
113 this.result = result;
114 }
115
116 public User getUser() {
117 return user;
118 }
119
120 public void setUser(User user) {
121 this.user = user;
122 }
123
124 public String[] getArray() {
125 return array;
126 }
127
128 public void setArray(String[] array) {
129 this.array = array;
130 }
131
132 public String[][] getList() {
133 return list;
134 }
135
136 public void setList(String[][] list) {
137 this.list = list;
138 }
139
140 public List getList2() {
141 return list2;
142 }
143
144 public void setList2(List list2) {
145 this.list2 = list2;
146 }
147
148 public void setList3(List list) {
149 this.list3 = list;
150 }
151
152 public List getList3() {
153 return this.list3;
154 }
155
156 public Collection getCollection2() {
157 return this.collection2;
158 }
159
160 public void setCollection2(Collection collection) {
161 this.collection2 = collection;
162 }
163
164 public Integer getFooInt() {
165 return fooInt;
166 }
167
168 public void setFooInt(Integer fooInt) {
169 this.fooInt = fooInt;
170 }
171
172 public String execute() throws Exception {
173 if (result == null) {
174 result = Action.SUCCESS;
175 }
176
177 return result;
178 }
179
180 public String doInput() throws Exception {
181 return INPUT;
182 }
183
184 public SomeEnum getStatus() {
185 return status;
186 }
187
188 public void setStatus(SomeEnum status) {
189 this.status = status;
190 }
191
192 public List<SomeEnum> getStatusList() {
193 return Arrays.asList(SomeEnum.values());
194 }
195
196 }