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.components;
23
24 import java.util.Map;
25
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
28
29 import org.apache.struts2.views.annotations.StrutsTagAttribute;
30
31 import com.opensymphony.xwork2.util.ValueStack;
32
33 /***
34 * DoubleListUIBean is the standard superclass of all Struts double list handling components.
35 *
36 * <p/>
37 *
38 * <!-- START SNIPPET: javadoc -->
39 *
40 * Note that the doublelistkey and doublelistvalue attribute will default to "key" and "value"
41 * respectively only when the doublelist attribute is evaluated to a Map or its decendant.
42 * Other thing else, will result in doublelistkey and doublelistvalue to be null and not used.
43 *
44 * <!-- END SNIPPET: javadoc -->
45 *
46 */
47 public abstract class DoubleListUIBean extends ListUIBean {
48
49 protected String emptyOption;
50 protected String headerKey;
51 protected String headerValue;
52 protected String multiple;
53 protected String size;
54
55 protected String doubleList;
56 protected String doubleListKey;
57 protected String doubleListValue;
58 protected String doubleName;
59 protected String doubleValue;
60 protected String formName;
61
62 protected String doubleId;
63 protected String doubleDisabled;
64 protected String doubleMultiple;
65 protected String doubleSize;
66 protected String doubleHeaderKey;
67 protected String doubleHeaderValue;
68 protected String doubleEmptyOption;
69
70 protected String doubleCssClass;
71 protected String doubleCssStyle;
72
73 protected String doubleOnclick;
74 protected String doubleOndblclick;
75 protected String doubleOnmousedown;
76 protected String doubleOnmouseup;
77 protected String doubleOnmouseover;
78 protected String doubleOnmousemove;
79 protected String doubleOnmouseout;
80 protected String doubleOnfocus;
81 protected String doubleOnblur;
82 protected String doubleOnkeypress;
83 protected String doubleOnkeydown;
84 protected String doubleOnkeyup;
85 protected String doubleOnselect;
86 protected String doubleOnchange;
87
88 protected String doubleAccesskey;
89
90
91 public DoubleListUIBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
92 super(stack, request, response);
93 }
94
95 public void evaluateExtraParams() {
96 super.evaluateExtraParams();
97
98
99
100 if (emptyOption != null) {
101 addParameter("emptyOption", findValue(emptyOption, Boolean.class));
102 }
103
104 if (multiple != null) {
105 addParameter("multiple", findValue(multiple, Boolean.class));
106 }
107
108 if (size != null) {
109 addParameter("size", findString(size));
110 }
111
112 if ((headerKey != null) && (headerValue != null)) {
113 addParameter("headerKey", findString(headerKey));
114 addParameter("headerValue", findString(headerValue));
115 }
116
117
118 if (doubleMultiple != null) {
119 addParameter("doubleMultiple", findValue(doubleMultiple, Boolean.class));
120 }
121
122 if (doubleSize != null) {
123 addParameter("doubleSize", findString(doubleSize));
124 }
125
126 if (doubleDisabled != null) {
127 addParameter("doubleDisabled", findValue(doubleDisabled, Boolean.class));
128 }
129
130 if (doubleName != null) {
131 addParameter("doubleName", findString(this.doubleName));
132 }
133
134 if (doubleList != null) {
135 addParameter("doubleList", doubleList);
136 }
137
138 Object tmpDoubleList = findValue(doubleList);
139 if (doubleListKey != null) {
140 addParameter("doubleListKey", doubleListKey);
141 }else if (tmpDoubleList instanceof Map) {
142 addParameter("doubleListKey", "key");
143 }
144
145 if (doubleListValue != null) {
146 if (altSyntax()) {
147
148
149 if (doubleListValue.startsWith("%{") && doubleListValue.endsWith("}")) {
150 doubleListValue = doubleListValue.substring(2, doubleListValue.length() - 1);
151 }
152 }
153
154 addParameter("doubleListValue", doubleListValue);
155 }else if (tmpDoubleList instanceof Map) {
156 addParameter("doubleListValue", "value");
157 }
158
159
160 if (formName != null) {
161 addParameter("formName", findString(formName));
162 } else {
163
164 Component form = findAncestor(Form.class);
165 if (form != null) {
166 addParameter("formName", form.getParameters().get("name"));
167 }
168 }
169
170 Class valueClazz = getValueClassType();
171
172 if (valueClazz != null) {
173 if (doubleValue != null) {
174 addParameter("doubleNameValue", findValue(doubleValue, valueClazz));
175 } else if (doubleName != null) {
176 addParameter("doubleNameValue", findValue(doubleName, valueClazz));
177 }
178 } else {
179 if (doubleValue != null) {
180 addParameter("doubleNameValue", findValue(doubleValue));
181 } else if (doubleName != null) {
182 addParameter("doubleNameValue", findValue(doubleName));
183 }
184 }
185
186 Form form = (Form) findAncestor(Form.class);
187 if (doubleId != null) {
188
189 if (altSyntax()) {
190 addParameter("doubleId", findString(doubleId));
191 } else {
192 addParameter("doubleId", doubleId);
193 }
194 } else if (form != null) {
195 addParameter("doubleId", form.getParameters().get("id") + "_" +escape(this.doubleName));
196 } else {
197 addParameter("doubleId", escape(doubleName != null ? findString(doubleName) : null));
198 }
199
200 if (doubleOnclick != null) {
201 addParameter("doubleOnclick", findString(doubleOnclick));
202 }
203
204 if (doubleOndblclick != null) {
205 addParameter("doubleOndblclick", findString(doubleOndblclick));
206 }
207
208 if (doubleOnmousedown != null) {
209 addParameter("doubleOnmousedown", findString(doubleOnmousedown));
210 }
211
212 if (doubleOnmouseup != null) {
213 addParameter("doubleOnmouseup", findString(doubleOnmouseup));
214 }
215
216 if (doubleOnmouseover != null) {
217 addParameter("doubleOnmouseover", findString(doubleOnmouseover));
218 }
219
220 if (doubleOnmousemove != null) {
221 addParameter("doubleOnmousemove", findString(doubleOnmousemove));
222 }
223
224 if (doubleOnmouseout != null) {
225 addParameter("doubleOnmouseout", findString(doubleOnmouseout));
226 }
227
228 if (doubleOnfocus != null) {
229 addParameter("doubleOnfocus", findString(doubleOnfocus));
230 }
231
232 if (doubleOnblur != null) {
233 addParameter("doubleOnblur", findString(doubleOnblur));
234 }
235
236 if (doubleOnkeypress != null) {
237 addParameter("doubleOnkeypress", findString(doubleOnkeypress));
238 }
239
240 if (doubleOnkeydown != null) {
241 addParameter("doubleOnkeydown", findString(doubleOnkeydown));
242 }
243
244 if (doubleOnselect != null) {
245 addParameter("doubleOnselect", findString(doubleOnselect));
246 }
247
248 if (doubleOnchange != null) {
249 addParameter("doubleOnchange", findString(doubleOnchange));
250 }
251
252 if (doubleCssClass != null) {
253 addParameter("doubleCss", findString(doubleCssClass));
254 }
255
256 if (doubleCssStyle != null) {
257 addParameter("doubleStyle", findString(doubleCssStyle));
258 }
259
260 if (doubleHeaderKey != null && doubleHeaderValue != null) {
261 addParameter("doubleHeaderKey", findString(doubleHeaderKey));
262 addParameter("doubleHeaderValue", findString(doubleHeaderValue));
263 }
264
265 if (doubleEmptyOption != null) {
266 addParameter("doubleEmptyOption", findValue(doubleEmptyOption, Boolean.class));
267 }
268
269 if (doubleAccesskey != null) {
270 addParameter("doubleAccesskey", findString(doubleAccesskey));
271 }
272 }
273
274 @StrutsTagAttribute(description="The second iterable source to populate from.", required=true)
275 public void setDoubleList(String doubleList) {
276 this.doubleList = doubleList;
277 }
278
279 @StrutsTagAttribute(description="The key expression to use for second list")
280 public void setDoubleListKey(String doubleListKey) {
281 this.doubleListKey = doubleListKey;
282 }
283
284 @StrutsTagAttribute(description="The value expression to use for second list")
285 public void setDoubleListValue(String doubleListValue) {
286 this.doubleListValue = doubleListValue;
287 }
288
289 @StrutsTagAttribute(description="The name for complete component", required=true)
290 public void setDoubleName(String doubleName) {
291 this.doubleName = doubleName;
292 }
293
294 @StrutsTagAttribute(description="The value expression for complete component")
295 public void setDoubleValue(String doubleValue) {
296 this.doubleValue = doubleValue;
297 }
298
299 @StrutsTagAttribute(description="The form name this component resides in and populates to")
300 public void setFormName(String formName) {
301 this.formName = formName;
302 }
303
304 public String getFormName() {
305 return formName;
306 }
307
308 @StrutsTagAttribute(description="The css class for the second list")
309 public void setDoubleCssClass(String doubleCssClass) {
310 this.doubleCssClass = doubleCssClass;
311 }
312
313 public String getDoubleCssClass() {
314 return doubleCssClass;
315 }
316
317 @StrutsTagAttribute(description="The css style for the second list")
318 public void setDoubleCssStyle(String doubleCssStyle) {
319 this.doubleCssStyle = doubleCssStyle;
320 }
321
322 public String getDoubleCssStyle() {
323 return doubleCssStyle;
324 }
325
326 @StrutsTagAttribute(description="The header key for the second list")
327 public void setDoubleHeaderKey(String doubleHeaderKey) {
328 this.doubleHeaderKey = doubleHeaderKey;
329 }
330
331 public String getDoubleHeaderKey() {
332 return doubleHeaderKey;
333 }
334
335 @StrutsTagAttribute(description="The header value for the second list")
336 public void setDoubleHeaderValue(String doubleHeaderValue) {
337 this.doubleHeaderValue = doubleHeaderValue;
338 }
339
340 public String getDoubleHeaderValue() {
341 return doubleHeaderValue;
342 }
343
344 @StrutsTagAttribute(description="Decides if the second list will add an empty option")
345 public void setDoubleEmptyOption(String doubleEmptyOption) {
346 this.doubleEmptyOption = doubleEmptyOption;
347 }
348
349 public String getDoubleEmptyOption() {
350 return this.doubleEmptyOption;
351 }
352
353
354 public String getDoubleDisabled() {
355 return doubleDisabled;
356 }
357
358 @StrutsTagAttribute(description="Decides if a disable attribute should be added to the second list")
359 public void setDoubleDisabled(String doubleDisabled) {
360 this.doubleDisabled = doubleDisabled;
361 }
362
363 public String getDoubleId() {
364 return doubleId;
365 }
366
367 @StrutsTagAttribute(description="The id of the second list")
368 public void setDoubleId(String doubleId) {
369 this.doubleId = doubleId;
370 }
371
372 public String getDoubleMultiple() {
373 return doubleMultiple;
374 }
375
376 @StrutsTagAttribute(description=" Decides if multiple attribute should be set on the second list")
377 public void setDoubleMultiple(String doubleMultiple) {
378 this.doubleMultiple = doubleMultiple;
379 }
380
381 public String getDoubleOnblur() {
382 return doubleOnblur;
383 }
384
385 @StrutsTagAttribute(description="Set the onblur attribute of the second list")
386 public void setDoubleOnblur(String doubleOnblur) {
387 this.doubleOnblur = doubleOnblur;
388 }
389
390 public String getDoubleOnchange() {
391 return doubleOnchange;
392 }
393
394 @StrutsTagAttribute(description="Set the onchange attribute of the second list")
395 public void setDoubleOnchange(String doubleOnchange) {
396 this.doubleOnchange = doubleOnchange;
397 }
398
399 public String getDoubleOnclick() {
400 return doubleOnclick;
401 }
402
403 @StrutsTagAttribute(description="Set the onclick attribute of the second list")
404 public void setDoubleOnclick(String doubleOnclick) {
405 this.doubleOnclick = doubleOnclick;
406 }
407
408 public String getDoubleOndblclick() {
409 return doubleOndblclick;
410 }
411
412 @StrutsTagAttribute(description="Set the ondbclick attribute of the second list")
413 public void setDoubleOndblclick(String doubleOndblclick) {
414 this.doubleOndblclick = doubleOndblclick;
415 }
416
417 public String getDoubleOnfocus() {
418 return doubleOnfocus;
419 }
420
421 @StrutsTagAttribute(description="Set the onfocus attribute of the second list")
422 public void setDoubleOnfocus(String doubleOnfocus) {
423 this.doubleOnfocus = doubleOnfocus;
424 }
425
426 public String getDoubleOnkeydown() {
427 return doubleOnkeydown;
428 }
429
430 @StrutsTagAttribute(description="Set the onkeydown attribute of the second list")
431 public void setDoubleOnkeydown(String doubleOnkeydown) {
432 this.doubleOnkeydown = doubleOnkeydown;
433 }
434
435 public String getDoubleOnkeypress() {
436 return doubleOnkeypress;
437 }
438
439 @StrutsTagAttribute(description="Set the onkeypress attribute of the second list")
440 public void setDoubleOnkeypress(String doubleOnkeypress) {
441 this.doubleOnkeypress = doubleOnkeypress;
442 }
443
444 public String getDoubleOnkeyup() {
445 return doubleOnkeyup;
446 }
447
448 @StrutsTagAttribute(description="Set the onkeyup attribute of the second list")
449 public void setDoubleOnkeyup(String doubleOnkeyup) {
450 this.doubleOnkeyup = doubleOnkeyup;
451 }
452
453 public String getDoubleOnmousedown() {
454 return doubleOnmousedown;
455 }
456
457 @StrutsTagAttribute(description="Set the onmousedown attribute of the second list")
458 public void setDoubleOnmousedown(String doubleOnmousedown) {
459 this.doubleOnmousedown = doubleOnmousedown;
460 }
461
462 public String getDoubleOnmousemove() {
463 return doubleOnmousemove;
464 }
465
466 @StrutsTagAttribute(description="Set the onmousemove attribute of the second list")
467 public void setDoubleOnmousemove(String doubleOnmousemove) {
468 this.doubleOnmousemove = doubleOnmousemove;
469 }
470
471 public String getDoubleOnmouseout() {
472 return doubleOnmouseout;
473 }
474
475 @StrutsTagAttribute(description="Set the onmouseout attribute of the second list")
476 public void setDoubleOnmouseout(String doubleOnmouseout) {
477 this.doubleOnmouseout = doubleOnmouseout;
478 }
479
480 public String getDoubleOnmouseover() {
481 return doubleOnmouseover;
482 }
483
484 @StrutsTagAttribute(description="Set the onmouseover attribute of the second list")
485 public void setDoubleOnmouseover(String doubleOnmouseover) {
486 this.doubleOnmouseover = doubleOnmouseover;
487 }
488
489 public String getDoubleOnmouseup() {
490 return doubleOnmouseup;
491 }
492
493 @StrutsTagAttribute(description="Set the onmouseup attribute of the second list")
494 public void setDoubleOnmouseup(String doubleOnmouseup) {
495 this.doubleOnmouseup = doubleOnmouseup;
496 }
497
498 public String getDoubleOnselect() {
499 return doubleOnselect;
500 }
501
502 @StrutsTagAttribute(description="Set the onselect attribute of the second list")
503 public void setDoubleOnselect(String doubleOnselect) {
504 this.doubleOnselect = doubleOnselect;
505 }
506
507 public String getDoubleSize() {
508 return doubleSize;
509 }
510
511 @StrutsTagAttribute(description="Set the size attribute of the second list")
512 public void setDoubleSize(String doubleSize) {
513 this.doubleSize = doubleSize;
514 }
515
516 public String getDoubleList() {
517 return doubleList;
518 }
519
520 public String getDoubleListKey() {
521 return doubleListKey;
522 }
523
524 public String getDoubleListValue() {
525 return doubleListValue;
526 }
527
528 public String getDoubleName() {
529 return doubleName;
530 }
531
532 public String getDoubleValue() {
533 return doubleValue;
534 }
535
536 @StrutsTagAttribute(description="Decides of an empty option is to be inserted in the second list", type="Boolean", defaultValue="false")
537 public void setEmptyOption(String emptyOption) {
538 this.emptyOption = emptyOption;
539 }
540
541 @StrutsTagAttribute(description="Set the header key of the second list. Must not be empty! " +
542 "'-1' and '' is correct, '' is bad.")
543 public void setHeaderKey(String headerKey) {
544 this.headerKey = headerKey;
545 }
546
547 @StrutsTagAttribute(description=" Set the header value of the second list")
548 public void setHeaderValue(String headerValue) {
549 this.headerValue = headerValue;
550 }
551
552 @StrutsTagAttribute(description="Creates a multiple select. " +
553 "The tag will pre-select multiple values if the values are passed as an Array " +
554 "(of appropriate types) via the value attribute.")
555 public void setMultiple(String multiple) {
556
557 this.multiple = multiple;
558 }
559
560 @StrutsTagAttribute(description="Size of the element box (# of elements to show)", type="Integer")
561 public void setSize(String size) {
562 this.size = size;
563 }
564
565 @StrutsTagAttribute(description="Set the html accesskey attribute.")
566 public void setDoubleAccesskey(String doubleAccesskey) {
567 this.doubleAccesskey = doubleAccesskey;
568 }
569 }