001: package com.opensymphony.webwork.components;
002:
003: import java.util.Map;
004:
005: import com.opensymphony.xwork.util.OgnlValueStack;
006:
007: import javax.servlet.http.HttpServletRequest;
008: import javax.servlet.http.HttpServletResponse;
009:
010: /**
011: * DoubleListUIBean is the standard superclass of all webwork double list handling components.
012: *
013: * <p/>
014: *
015: * <!-- START SNIPPET: javadoc -->
016: *
017: * Note that the doublelistkey and doublelistvalue attribute will default to "key" and "value"
018: * respectively only when the doublelist attribute is evaluated to a Map or its decendant.
019: * Other thing else, will result in doublelistkey and doublelistvalue to be null and not used.
020: *
021: * <!-- END SNIPPET: javadoc -->
022: *
023: *
024: * @author Patrick Lightbody
025: * @author Rene Gielen
026: * @author Rainer Hermanns
027: * @author tm_jee
028: * @version $Revision: 2709 $
029: * @since 2.2
030: */
031: public abstract class DoubleListUIBean extends ListUIBean {
032:
033: protected String emptyOption;
034: protected String headerKey;
035: protected String headerValue;
036: protected String multiple;
037: protected String size;
038:
039: protected String doubleList;
040: protected String doubleListKey;
041: protected String doubleListValue;
042: protected String doubleName;
043: protected String doubleValue;
044: protected String formName;
045:
046: protected String doubleId;
047: protected String doubleDisabled;
048: protected String doubleMultiple;
049: protected String doubleSize;
050: protected String doubleHeaderKey;
051: protected String doubleHeaderValue;
052: protected String doubleEmptyOption;
053:
054: protected String doubleCssClass;
055: protected String doubleCssStyle;
056:
057: protected String doubleOnclick;
058: protected String doubleOndblclick;
059: protected String doubleOnmousedown;
060: protected String doubleOnmouseup;
061: protected String doubleOnmouseover;
062: protected String doubleOnmousemove;
063: protected String doubleOnmouseout;
064: protected String doubleOnfocus;
065: protected String doubleOnblur;
066: protected String doubleOnkeypress;
067: protected String doubleOnkeydown;
068: protected String doubleOnkeyup;
069: protected String doubleOnselect;
070: protected String doubleOnchange;
071:
072: protected String doubleAccesskey;
073:
074: public DoubleListUIBean(OgnlValueStack stack,
075: HttpServletRequest request, HttpServletResponse response) {
076: super (stack, request, response);
077: }
078:
079: public void evaluateExtraParams() {
080: super .evaluateExtraParams();
081:
082: //Object doubleName = null;
083:
084: if (emptyOption != null) {
085: addParameter("emptyOption", findValue(emptyOption,
086: Boolean.class));
087: }
088:
089: if (multiple != null) {
090: addParameter("multiple", findValue(multiple, Boolean.class));
091: }
092:
093: if (size != null) {
094: addParameter("size", findString(size));
095: }
096:
097: if ((headerKey != null) && (headerValue != null)) {
098: addParameter("headerKey", findString(headerKey));
099: addParameter("headerValue", findString(headerValue));
100: }
101:
102: if (doubleMultiple != null) {
103: addParameter("doubleMultiple", findValue(doubleMultiple,
104: Boolean.class));
105: }
106:
107: if (doubleSize != null) {
108: addParameter("doubleSize", findString(doubleSize));
109: }
110:
111: if (doubleDisabled != null) {
112: addParameter("doubleDisabled", findValue(doubleDisabled,
113: Boolean.class));
114: }
115:
116: if (doubleName != null) {
117: addParameter("doubleName", findString(this .doubleName));
118: }
119:
120: if (doubleList != null) {
121: addParameter("doubleList", doubleList);
122: }
123:
124: Object tmpDoubleList = findValue(doubleList);
125: if (doubleListKey != null) {
126: addParameter("doubleListKey", doubleListKey);
127: } else if (tmpDoubleList instanceof Map) {
128: addParameter("doubleListKey", "key");
129: }
130:
131: if (doubleListValue != null) {
132: if (altSyntax()) {
133: // the same logic as with findValue(String)
134: // if value start with %{ and end with }, just cut it off!
135: if (doubleListValue.startsWith("%{")
136: && doubleListValue.endsWith("}")) {
137: doubleListValue = doubleListValue.substring(2,
138: doubleListValue.length() - 1);
139: }
140: }
141:
142: addParameter("doubleListValue", doubleListValue);
143: } else if (tmpDoubleList instanceof Map) {
144: addParameter("doubleListValue", "value");
145: }
146:
147: if (formName != null) {
148: addParameter("formName", findString(formName));
149: } else {
150: // ok, let's look it up
151: Component form = findAncestor(Form.class);
152: if (form != null) {
153: addParameter("formName", form.getParameters().get(
154: "name"));
155: }
156: }
157:
158: Class valueClazz = getValueClassType();
159:
160: if (valueClazz != null) {
161: if (doubleValue != null) {
162: addParameter("doubleNameValue", findValue(doubleValue,
163: valueClazz));
164: } else if (doubleName != null) {
165: addParameter("doubleNameValue", findValue(doubleName
166: .toString(), valueClazz));
167: }
168: } else {
169: if (doubleValue != null) {
170: addParameter("doubleNameValue", findValue(doubleValue));
171: } else if (doubleName != null) {
172: addParameter("doubleNameValue", findValue(doubleName
173: .toString()));
174: }
175: }
176:
177: Form form = (Form) findAncestor(Form.class);
178: if (doubleId != null) {
179: // this check is needed for backwards compatibility with 2.1.x
180: if (altSyntax()) {
181: addParameter("doubleId", findString(doubleId));
182: } else {
183: addParameter("doubleId", doubleId);
184: }
185: } else if (form != null) {
186: addParameter("doubleId", form.getParameters().get("id")
187: + "_" + escape(this .doubleName));
188: }
189:
190: if (doubleOnclick != null) {
191: addParameter("doubleOnclick", findString(doubleOnclick));
192: }
193:
194: if (doubleOndblclick != null) {
195: addParameter("doubleOndblclick",
196: findString(doubleOndblclick));
197: }
198:
199: if (doubleOnmousedown != null) {
200: addParameter("doubleOnmousedown",
201: findString(doubleOnmousedown));
202: }
203:
204: if (doubleOnmouseup != null) {
205: addParameter("doubleOnmouseup", findString(doubleOnmouseup));
206: }
207:
208: if (doubleOnmouseover != null) {
209: addParameter("doubleOnmouseover",
210: findString(doubleOnmouseover));
211: }
212:
213: if (doubleOnmousemove != null) {
214: addParameter("doubleOnmousemove",
215: findString(doubleOnmousemove));
216: }
217:
218: if (doubleOnmouseout != null) {
219: addParameter("doubleOnmouseout",
220: findString(doubleOnmouseout));
221: }
222:
223: if (doubleOnfocus != null) {
224: addParameter("doubleOnfocus", findString(doubleOnfocus));
225: }
226:
227: if (doubleOnblur != null) {
228: addParameter("doubleOnblur", findString(doubleOnblur));
229: }
230:
231: if (doubleOnkeypress != null) {
232: addParameter("doubleOnkeypress",
233: findString(doubleOnkeypress));
234: }
235:
236: if (doubleOnkeydown != null) {
237: addParameter("doubleOnkeydown", findString(doubleOnkeydown));
238: }
239:
240: if (doubleOnselect != null) {
241: addParameter("doubleOnselect", findString(doubleOnselect));
242: }
243:
244: if (doubleOnchange != null) {
245: addParameter("doubleOnchange", findString(doubleOnchange));
246: }
247:
248: if (doubleCssClass != null) {
249: addParameter("doubleCss", findString(doubleCssClass));
250: }
251:
252: if (doubleCssStyle != null) {
253: addParameter("doubleStyle", findString(doubleCssStyle));
254: }
255:
256: if (doubleHeaderKey != null && doubleHeaderValue != null) {
257: addParameter("doubleHeaderKey", findString(doubleHeaderKey));
258: addParameter("doubleHeaderValue",
259: findString(doubleHeaderValue));
260: }
261:
262: if (doubleEmptyOption != null) {
263: addParameter("doubleEmptyOption", findValue(
264: doubleEmptyOption, Boolean.class));
265: }
266:
267: if (doubleAccesskey != null) {
268: addParameter("doubleAccesskey", findString(doubleAccesskey));
269: }
270: }
271:
272: /**
273: * The second iterable source to populate from.
274: * @ww.tagattribute required="true"
275: */
276: public void setDoubleList(String doubleList) {
277: this .doubleList = doubleList;
278: }
279:
280: /**
281: * The key expression to use for second list
282: * @ww.tagattribute required="false"
283: */
284: public void setDoubleListKey(String doubleListKey) {
285: this .doubleListKey = doubleListKey;
286: }
287:
288: /**
289: * The value expression to use for second list
290: * @ww.tagattribute required="false"
291: */
292: public void setDoubleListValue(String doubleListValue) {
293: this .doubleListValue = doubleListValue;
294: }
295:
296: /**
297: * The name for complete component
298: * @ww.tagattribute required="true"
299: */
300: public void setDoubleName(String doubleName) {
301: this .doubleName = doubleName;
302: }
303:
304: /**
305: * The value expression for complete component
306: * @ww.tagattribute required="false"
307: */
308: public void setDoubleValue(String doubleValue) {
309: this .doubleValue = doubleValue;
310: }
311:
312: /**
313: * The form name this component resides in and populates to
314: * @ww.tagattribute required="false"
315: */
316: public void setFormName(String formName) {
317: this .formName = formName;
318: }
319:
320: public String getFormName() {
321: return formName;
322: }
323:
324: /**
325: * The css class for the second list
326: * @ww.tagattribute required="false"
327: */
328: public void setDoubleCssClass(String doubleCssClass) {
329: this .doubleCssClass = doubleCssClass;
330: }
331:
332: public String getDoubleCssClass() {
333: return doubleCssClass;
334: }
335:
336: /**
337: * The css style for the second list
338: * @ww.tagattribute required="false"
339: */
340: public void setDoubleCssStyle(String doubleCssStyle) {
341: this .doubleCssStyle = doubleCssStyle;
342: }
343:
344: public String getDoubleCssStyle() {
345: return doubleCssStyle;
346: }
347:
348: /**
349: * The header key for the second list
350: * @ww.tagattribute required="false"
351: */
352: public void setDoubleHeaderKey(String doubleHeaderKey) {
353: this .doubleHeaderKey = doubleHeaderKey;
354: }
355:
356: public String getDoubleHeaderKey() {
357: return doubleHeaderKey;
358: }
359:
360: /**
361: * The header value for the second list
362: * @ww.tagattribute required="false"
363: */
364: public void setDoubleHeaderValue(String doubleHeaderValue) {
365: this .doubleHeaderValue = doubleHeaderValue;
366: }
367:
368: public String getDoubleHeaderValue() {
369: return doubleHeaderValue;
370: }
371:
372: /**
373: * Decides if the second list will add an empty option
374: * @ww.tagattribute required="false"
375: */
376: public void setDoubleEmptyOption(String doubleEmptyOption) {
377: this .doubleEmptyOption = doubleEmptyOption;
378: }
379:
380: public String getDoubleEmptyOption() {
381: return this .doubleEmptyOption;
382: }
383:
384: public String getDoubleDisabled() {
385: return doubleDisabled;
386: }
387:
388: /**
389: * Decides if a disable attribute should be added to the second list
390: * @ww.tagattribute required="false"
391: */
392: public void setDoubleDisabled(String doubleDisabled) {
393: this .doubleDisabled = doubleDisabled;
394: }
395:
396: public String getDoubleId() {
397: return doubleId;
398: }
399:
400: /**
401: * The id of the second list
402: * @ww.tagattribute required="false"
403: */
404: public void setDoubleId(String doubleId) {
405: this .doubleId = doubleId;
406: }
407:
408: public String getDoubleMultiple() {
409: return doubleMultiple;
410: }
411:
412: /**
413: * Decides if multiple attribute should be set on the second list
414: * @ww.tagattribute required="false"
415: */
416: public void setDoubleMultiple(String doubleMultiple) {
417: this .doubleMultiple = doubleMultiple;
418: }
419:
420: public String getDoubleOnblur() {
421: return doubleOnblur;
422: }
423:
424: /**
425: * Set the onblur attribute of the second list
426: * @ww.tagattribute required="false"
427: */
428: public void setDoubleOnblur(String doubleOnblur) {
429: this .doubleOnblur = doubleOnblur;
430: }
431:
432: public String getDoubleOnchange() {
433: return doubleOnchange;
434: }
435:
436: /**
437: * Set the onchange attribute of the second list
438: * @ww.tagattribute required="false"
439: */
440: public void setDoubleOnchange(String doubleOnchange) {
441: this .doubleOnchange = doubleOnchange;
442: }
443:
444: public String getDoubleOnclick() {
445: return doubleOnclick;
446: }
447:
448: /**
449: * Set the onclick attribute of the second list
450: * @ww.tagattribute required="false"
451: */
452: public void setDoubleOnclick(String doubleOnclick) {
453: this .doubleOnclick = doubleOnclick;
454: }
455:
456: public String getDoubleOndblclick() {
457: return doubleOndblclick;
458: }
459:
460: /**
461: * Set the ondbclick attribute of the second list
462: * @ww.tagattribute required="false"
463: */
464: public void setDoubleOndblclick(String doubleOndblclick) {
465: this .doubleOndblclick = doubleOndblclick;
466: }
467:
468: public String getDoubleOnfocus() {
469: return doubleOnfocus;
470: }
471:
472: /**
473: * Set the onfocus attribute of the second list
474: * @ww.tagattribute required="false"
475: */
476: public void setDoubleOnfocus(String doubleOnfocus) {
477: this .doubleOnfocus = doubleOnfocus;
478: }
479:
480: public String getDoubleOnkeydown() {
481: return doubleOnkeydown;
482: }
483:
484: /**
485: * Set the onkeydown attribute of the second list
486: * @ww.tagattribute required="false"
487: */
488: public void setDoubleOnkeydown(String doubleOnkeydown) {
489: this .doubleOnkeydown = doubleOnkeydown;
490: }
491:
492: public String getDoubleOnkeypress() {
493: return doubleOnkeypress;
494: }
495:
496: /**
497: * Set the onkeypress attribute of the second list
498: * @ww.tagattribute required="false"
499: */
500: public void setDoubleOnkeypress(String doubleOnkeypress) {
501: this .doubleOnkeypress = doubleOnkeypress;
502: }
503:
504: public String getDoubleOnkeyup() {
505: return doubleOnkeyup;
506: }
507:
508: /**
509: * Set the onkeyup attribute of the second list
510: * @ww.tagattribute required="false"
511: */
512: public void setDoubleOnkeyup(String doubleOnkeyup) {
513: this .doubleOnkeyup = doubleOnkeyup;
514: }
515:
516: public String getDoubleOnmousedown() {
517: return doubleOnmousedown;
518: }
519:
520: /**
521: * Set the onmousedown attribute of the second list
522: * @ww.tagattribute required="false"
523: */
524: public void setDoubleOnmousedown(String doubleOnmousedown) {
525: this .doubleOnmousedown = doubleOnmousedown;
526: }
527:
528: public String getDoubleOnmousemove() {
529: return doubleOnmousemove;
530: }
531:
532: /**
533: * Set the onmousemove attribute of the second list
534: * @ww.tagattribute required="false"
535: */
536: public void setDoubleOnmousemove(String doubleOnmousemove) {
537: this .doubleOnmousemove = doubleOnmousemove;
538: }
539:
540: public String getDoubleOnmouseout() {
541: return doubleOnmouseout;
542: }
543:
544: /**
545: * Set the onmouseout attribute of the second list
546: * @ww.tagattribute required="false"
547: */
548: public void setDoubleOnmouseout(String doubleOnmouseout) {
549: this .doubleOnmouseout = doubleOnmouseout;
550: }
551:
552: public String getDoubleOnmouseover() {
553: return doubleOnmouseover;
554: }
555:
556: /**
557: * Set the onmouseover attribute of the second list
558: * @ww.tagattribute required="false"
559: */
560: public void setDoubleOnmouseover(String doubleOnmouseover) {
561: this .doubleOnmouseover = doubleOnmouseover;
562: }
563:
564: public String getDoubleOnmouseup() {
565: return doubleOnmouseup;
566: }
567:
568: /**
569: * Set the onmouseup attribute of the second list
570: * @ww.tagattribute required="false"
571: */
572: public void setDoubleOnmouseup(String doubleOnmouseup) {
573: this .doubleOnmouseup = doubleOnmouseup;
574: }
575:
576: public String getDoubleOnselect() {
577: return doubleOnselect;
578: }
579:
580: /**
581: * Set the onselect attribute of the second list
582: * @ww.tagattribute required="false"
583: */
584: public void setDoubleOnselect(String doubleOnselect) {
585: this .doubleOnselect = doubleOnselect;
586: }
587:
588: public String getDoubleSize() {
589: return doubleSize;
590: }
591:
592: /**
593: * Set the size attribute of the second list
594: * @ww.tagattribute required="false"
595: */
596: public void setDoubleSize(String doubleSize) {
597: this .doubleSize = doubleSize;
598: }
599:
600: public String getDoubleList() {
601: return doubleList;
602: }
603:
604: /**
605: * Set the list key of the second attribute
606: * @ww.tagattribute required="false"
607: */
608: public String getDoubleListKey() {
609: return doubleListKey;
610: }
611:
612: public String getDoubleListValue() {
613: return doubleListValue;
614: }
615:
616: public String getDoubleName() {
617: return doubleName;
618: }
619:
620: public String getDoubleValue() {
621: return doubleValue;
622: }
623:
624: /**
625: * Decides of an empty option is to be inserted in the second list
626: * @ww.tagattribute required="false" default="false" type="Boolean"
627: */
628: public void setEmptyOption(String emptyOption) {
629: this .emptyOption = emptyOption;
630: }
631:
632: /**
633: * Set the header key of the second list. Must not be empty! "'-1'" and "''" is correct, "" is bad.
634: * @ww.tagattribute required="false"
635: */
636: public void setHeaderKey(String headerKey) {
637: this .headerKey = headerKey;
638: }
639:
640: /**
641: * Set the header value of the second list
642: * @ww.tagattribute required="false"
643: */
644: public void setHeaderValue(String headerValue) {
645: this .headerValue = headerValue;
646: }
647:
648: /**
649: * Creates a multiple select. The tag will pre-select multiple values if the values are passed as an Array (of appropriate types) via the value attribute.
650: * @ww.tagattribute required="false"
651: */
652: public void setMultiple(String multiple) {
653: // TODO: Passing a Collection may work too?
654: this .multiple = multiple;
655: }
656:
657: /**
658: * Size of the element box (# of elements to show)
659: * @ww.tagattribute required="false" type="Integer"
660: */
661: public void setSize(String size) {
662: this .size = size;
663: }
664:
665: /**
666: * Accesskey attribute of the second list.
667: * @param doubleAccesskey
668: */
669: public void setDoubleAccesskey(String doubleAccesskey) {
670: this.doubleAccesskey = doubleAccesskey;
671: }
672: }
|