001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License version 2
011: * as published by the Free Software Foundation.
012: *
013: * Resin Open Source is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
016: * of NON-INFRINGEMENT. See the GNU General Public License for more
017: * details.
018: *
019: * You should have received a copy of the GNU General Public License
020: * along with Resin Open Source; if not, write to the
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package javax.faces.component.html;
030:
031: import java.util.*;
032:
033: import javax.el.*;
034:
035: import javax.faces.component.*;
036: import javax.faces.context.*;
037:
038: public class HtmlSelectManyListbox extends UISelectMany {
039: public static final String COMPONENT_TYPE = "javax.faces.HtmlSelectManyListbox";
040:
041: private static final HashMap<String, PropEnum> _propMap = new HashMap<String, PropEnum>();
042:
043: private String _accesskey;
044: private ValueExpression _accesskeyExpr;
045:
046: private String _dir;
047: private ValueExpression _dirExpr;
048:
049: private Boolean _disabled;
050: private ValueExpression _disabledExpr;
051:
052: private String _disabledClass;
053: private ValueExpression _disabledClassExpr;
054:
055: private String _enabledClass;
056: private ValueExpression _enabledClassExpr;
057:
058: private String _label;
059: private ValueExpression _labelExpr;
060:
061: private String _lang;
062: private ValueExpression _langExpr;
063:
064: private String _onblur;
065: private ValueExpression _onblurExpr;
066:
067: private String _onchange;
068: private ValueExpression _onchangeExpr;
069:
070: private String _onclick;
071: private ValueExpression _onclickExpr;
072:
073: private String _ondblclick;
074: private ValueExpression _ondblclickExpr;
075:
076: private String _onfocus;
077: private ValueExpression _onfocusExpr;
078:
079: private String _onkeydown;
080: private ValueExpression _onkeydownExpr;
081:
082: private String _onkeypress;
083: private ValueExpression _onkeypressExpr;
084:
085: private String _onkeyup;
086: private ValueExpression _onkeyupExpr;
087:
088: private String _onmousedown;
089: private ValueExpression _onmousedownExpr;
090:
091: private String _onmousemove;
092: private ValueExpression _onmousemoveExpr;
093:
094: private String _onmouseout;
095: private ValueExpression _onmouseoutExpr;
096:
097: private String _onmouseover;
098: private ValueExpression _onmouseoverExpr;
099:
100: private String _onmouseup;
101: private ValueExpression _onmouseupExpr;
102:
103: private String _onselect;
104: private ValueExpression _onselectExpr;
105:
106: private Boolean _readonly;
107: private ValueExpression _readonlyExpr;
108:
109: private Integer _size;
110: private ValueExpression _sizeExpr;
111:
112: private String _style;
113: private ValueExpression _styleExpr;
114:
115: private String _styleClass;
116: private ValueExpression _styleClassExpr;
117:
118: private String _tabindex;
119: private ValueExpression _tabindexExpr;
120:
121: private String _title;
122: private ValueExpression _titleExpr;
123:
124: public HtmlSelectManyListbox() {
125: setRendererType("javax.faces.Listbox");
126: }
127:
128: //
129: // properties
130: //
131:
132: public String getAccesskey() {
133: if (_accesskey != null)
134: return _accesskey;
135: else if (_accesskeyExpr != null)
136: return Util.evalString(_accesskeyExpr);
137: else
138: return null;
139: }
140:
141: public void setAccesskey(String value) {
142: _accesskey = value;
143: }
144:
145: public String getDir() {
146: if (_dir != null)
147: return _dir;
148: else if (_dirExpr != null)
149: return Util.evalString(_dirExpr);
150: else
151: return null;
152: }
153:
154: public void setDir(String value) {
155: _dir = value;
156: }
157:
158: public String getDisabledClass() {
159: if (_disabledClass != null)
160: return _disabledClass;
161: else if (_disabledClassExpr != null)
162: return Util.evalString(_disabledClassExpr);
163: else
164: return null;
165: }
166:
167: public void setDisabledClass(String value) {
168: _disabledClass = value;
169: }
170:
171: public String getEnabledClass() {
172: if (_enabledClass != null)
173: return _enabledClass;
174: else if (_enabledClassExpr != null)
175: return Util.evalString(_enabledClassExpr);
176: else
177: return null;
178: }
179:
180: public void setEnabledClass(String value) {
181: _enabledClass = value;
182: }
183:
184: public boolean isDisabled() {
185: if (_disabled != null)
186: return _disabled;
187: else if (_disabledExpr != null)
188: return Util.evalBoolean(_disabledExpr);
189: else
190: return false;
191: }
192:
193: public void setDisabled(boolean value) {
194: _disabled = value;
195: }
196:
197: public String getLabel() {
198: if (_label != null)
199: return _label;
200: else if (_labelExpr != null)
201: return Util.evalString(_labelExpr);
202: else
203: return null;
204: }
205:
206: public void setLabel(String value) {
207: _label = value;
208: }
209:
210: public String getLang() {
211: if (_lang != null)
212: return _lang;
213: else if (_langExpr != null)
214: return Util.evalString(_langExpr);
215: else
216: return null;
217: }
218:
219: public void setLang(String value) {
220: _lang = value;
221: }
222:
223: public String getOnblur() {
224: if (_onblur != null)
225: return _onblur;
226: else if (_onblurExpr != null)
227: return Util.evalString(_onblurExpr);
228: else
229: return null;
230: }
231:
232: public void setOnblur(String value) {
233: _onblur = value;
234: }
235:
236: public String getOnchange() {
237: if (_onchange != null)
238: return _onchange;
239: else if (_onchangeExpr != null)
240: return Util.evalString(_onchangeExpr);
241: else
242: return null;
243: }
244:
245: public void setOnchange(String value) {
246: _onchange = value;
247: }
248:
249: public String getOnclick() {
250: if (_onclick != null)
251: return _onclick;
252: else if (_onclickExpr != null)
253: return Util.evalString(_onclickExpr);
254: else
255: return null;
256: }
257:
258: public void setOnclick(String value) {
259: _onclick = value;
260: }
261:
262: public String getOndblclick() {
263: if (_ondblclick != null)
264: return _ondblclick;
265: else if (_ondblclickExpr != null)
266: return Util.evalString(_ondblclickExpr);
267: else
268: return null;
269: }
270:
271: public void setOndblclick(String value) {
272: _ondblclick = value;
273: }
274:
275: public String getOnfocus() {
276: if (_onfocus != null)
277: return _onfocus;
278: else if (_onfocusExpr != null)
279: return Util.evalString(_onfocusExpr);
280: else
281: return null;
282: }
283:
284: public void setOnfocus(String value) {
285: _onfocus = value;
286: }
287:
288: public String getOnkeydown() {
289: if (_onkeydown != null)
290: return _onkeydown;
291: else if (_onkeydownExpr != null)
292: return Util.evalString(_onkeydownExpr);
293: else
294: return null;
295: }
296:
297: public void setOnkeydown(String value) {
298: _onkeydown = value;
299: }
300:
301: public String getOnkeypress() {
302: if (_onkeypress != null)
303: return _onkeypress;
304: else if (_onkeypressExpr != null)
305: return Util.evalString(_onkeypressExpr);
306: else
307: return null;
308: }
309:
310: public void setOnkeypress(String value) {
311: _onkeypress = value;
312: }
313:
314: public String getOnkeyup() {
315: if (_onkeyup != null)
316: return _onkeyup;
317: else if (_onkeyupExpr != null)
318: return Util.evalString(_onkeyupExpr);
319: else
320: return null;
321: }
322:
323: public void setOnkeyup(String value) {
324: _onkeyup = value;
325: }
326:
327: public String getOnmousedown() {
328: if (_onmousedown != null)
329: return _onmousedown;
330: else if (_onmousedownExpr != null)
331: return Util.evalString(_onmousedownExpr);
332: else
333: return null;
334: }
335:
336: public void setOnmousedown(String value) {
337: _onmousedown = value;
338: }
339:
340: public String getOnmousemove() {
341: if (_onmousemove != null)
342: return _onmousemove;
343: else if (_onmousemoveExpr != null)
344: return Util.evalString(_onmousemoveExpr);
345: else
346: return null;
347: }
348:
349: public void setOnmousemove(String value) {
350: _onmousemove = value;
351: }
352:
353: public String getOnmouseout() {
354: if (_onmouseout != null)
355: return _onmouseout;
356: else if (_onmouseoutExpr != null)
357: return Util.evalString(_onmouseoutExpr);
358: else
359: return null;
360: }
361:
362: public void setOnmouseout(String value) {
363: _onmouseout = value;
364: }
365:
366: public String getOnmouseover() {
367: if (_onmouseover != null)
368: return _onmouseover;
369: else if (_onmouseoverExpr != null)
370: return Util.evalString(_onmouseoverExpr);
371: else
372: return null;
373: }
374:
375: public void setOnmouseover(String value) {
376: _onmouseover = value;
377: }
378:
379: public String getOnmouseup() {
380: if (_onmouseup != null)
381: return _onmouseup;
382: else if (_onmouseupExpr != null)
383: return Util.evalString(_onmouseupExpr);
384: else
385: return null;
386: }
387:
388: public void setOnmouseup(String value) {
389: _onmouseup = value;
390: }
391:
392: public String getOnselect() {
393: if (_onselect != null)
394: return _onselect;
395: else if (_onselectExpr != null)
396: return Util.evalString(_onselectExpr);
397: else
398: return null;
399: }
400:
401: public void setOnselect(String value) {
402: _onselect = value;
403: }
404:
405: public boolean isReadonly() {
406: if (_readonly != null)
407: return _readonly;
408: else if (_readonlyExpr != null)
409: return Util.evalBoolean(_readonlyExpr);
410: else
411: return false;
412: }
413:
414: public void setReadonly(boolean value) {
415: _readonly = value;
416: }
417:
418: public int getSize() {
419: if (_size != null)
420: return _size;
421: else if (_sizeExpr != null)
422: return Util.evalInt(_sizeExpr);
423: else
424: return Integer.MIN_VALUE;
425: }
426:
427: public void setSize(int value) {
428: _size = value;
429: }
430:
431: public String getStyle() {
432: if (_style != null)
433: return _style;
434: else if (_styleExpr != null)
435: return Util.evalString(_styleExpr);
436: else
437: return null;
438: }
439:
440: public void setStyle(String value) {
441: _style = value;
442: }
443:
444: public String getStyleClass() {
445: if (_styleClass != null)
446: return _styleClass;
447: else if (_styleClassExpr != null)
448: return Util.evalString(_styleClassExpr);
449: else
450: return null;
451: }
452:
453: public void setStyleClass(String value) {
454: _styleClass = value;
455: }
456:
457: public String getTabindex() {
458: if (_tabindex != null)
459: return _tabindex;
460: else if (_tabindexExpr != null)
461: return Util.evalString(_tabindexExpr);
462: else
463: return null;
464: }
465:
466: public void setTabindex(String value) {
467: _tabindex = value;
468: }
469:
470: public String getTitle() {
471: if (_title != null)
472: return _title;
473: else if (_titleExpr != null)
474: return Util.evalString(_titleExpr);
475: else
476: return null;
477: }
478:
479: public void setTitle(String value) {
480: _title = value;
481: }
482:
483: //
484: // value expression override
485: //
486:
487: /**
488: * Returns the value expression with the given name.
489: */
490: @Override
491: public ValueExpression getValueExpression(String name) {
492: PropEnum prop = _propMap.get(name);
493:
494: if (prop != null) {
495: switch (prop) {
496: case ACCESSKEY:
497: return _accesskeyExpr;
498: case DIR:
499: return _dirExpr;
500: case DISABLED:
501: return _disabledExpr;
502: case DISABLED_CLASS:
503: return _disabledClassExpr;
504: case ENABLED_CLASS:
505: return _enabledClassExpr;
506: case LABEL:
507: return _labelExpr;
508: case LANG:
509: return _langExpr;
510: case ONBLUR:
511: return _onblurExpr;
512: case ONCHANGE:
513: return _onchangeExpr;
514: case ONCLICK:
515: return _onclickExpr;
516: case ONDBLCLICK:
517: return _ondblclickExpr;
518: case ONFOCUS:
519: return _onfocusExpr;
520: case ONKEYDOWN:
521: return _onkeydownExpr;
522: case ONKEYPRESS:
523: return _onkeypressExpr;
524: case ONKEYUP:
525: return _onkeyupExpr;
526: case ONMOUSEDOWN:
527: return _onmousedownExpr;
528: case ONMOUSEMOVE:
529: return _onmousemoveExpr;
530: case ONMOUSEOUT:
531: return _onmouseoutExpr;
532: case ONMOUSEOVER:
533: return _onmouseoverExpr;
534: case ONMOUSEUP:
535: return _onmouseupExpr;
536: case ONSELECT:
537: return _onselectExpr;
538: case READONLY:
539: return _readonlyExpr;
540: case SIZE:
541: return _sizeExpr;
542: case STYLE:
543: return _styleExpr;
544: case STYLE_CLASS:
545: return _styleClassExpr;
546: case TABINDEX:
547: return _tabindexExpr;
548: case TITLE:
549: return _titleExpr;
550: }
551: }
552:
553: return super .getValueExpression(name);
554: }
555:
556: /**
557: * Sets the value expression with the given name.
558: */
559: @Override
560: public void setValueExpression(String name, ValueExpression expr) {
561: PropEnum prop = _propMap.get(name);
562:
563: if (prop != null) {
564: switch (prop) {
565: case ACCESSKEY:
566: if (expr != null && expr.isLiteralText()) {
567: _accesskey = Util.evalString(expr);
568: return;
569: } else
570: _accesskeyExpr = expr;
571: break;
572:
573: case DIR:
574: if (expr != null && expr.isLiteralText()) {
575: _dir = Util.evalString(expr);
576: return;
577: } else
578: _dirExpr = expr;
579: break;
580:
581: case DISABLED:
582: if (expr != null && expr.isLiteralText()) {
583: _disabled = Util.evalBoolean(expr);
584: return;
585: } else
586: _disabledExpr = expr;
587: break;
588:
589: case DISABLED_CLASS:
590: if (expr != null && expr.isLiteralText()) {
591: _disabledClass = Util.evalString(expr);
592: return;
593: } else
594: _disabledClassExpr = expr;
595: break;
596:
597: case ENABLED_CLASS:
598: if (expr != null && expr.isLiteralText()) {
599: _enabledClass = Util.evalString(expr);
600: return;
601: } else
602: _enabledClassExpr = expr;
603: break;
604:
605: case LABEL:
606: if (expr != null && expr.isLiteralText()) {
607: _label = Util.evalString(expr);
608: return;
609: } else
610: _labelExpr = expr;
611: break;
612:
613: case LANG:
614: if (expr != null && expr.isLiteralText()) {
615: _lang = Util.evalString(expr);
616: return;
617: } else
618: _langExpr = expr;
619: break;
620:
621: case ONBLUR:
622: if (expr != null && expr.isLiteralText()) {
623: _onblur = Util.evalString(expr);
624: return;
625: } else
626: _onblurExpr = expr;
627: break;
628:
629: case ONCHANGE:
630: if (expr != null && expr.isLiteralText()) {
631: _onchange = Util.evalString(expr);
632: return;
633: } else
634: _onchangeExpr = expr;
635: break;
636:
637: case ONCLICK:
638: if (expr != null && expr.isLiteralText()) {
639: _onclick = Util.evalString(expr);
640: return;
641: } else
642: _onclickExpr = expr;
643: break;
644:
645: case ONDBLCLICK:
646: if (expr != null && expr.isLiteralText()) {
647: _ondblclick = Util.evalString(expr);
648: return;
649: } else
650: _ondblclickExpr = expr;
651: break;
652:
653: case ONFOCUS:
654: if (expr != null && expr.isLiteralText()) {
655: _onfocus = Util.evalString(expr);
656: return;
657: } else
658: _onfocusExpr = expr;
659: break;
660:
661: case ONKEYDOWN:
662: if (expr != null && expr.isLiteralText()) {
663: _onkeydown = Util.evalString(expr);
664: return;
665: } else
666: _onkeydownExpr = expr;
667: break;
668:
669: case ONKEYPRESS:
670: if (expr != null && expr.isLiteralText()) {
671: _onkeypress = Util.evalString(expr);
672: return;
673: } else
674: _onkeypressExpr = expr;
675: break;
676:
677: case ONKEYUP:
678: if (expr != null && expr.isLiteralText()) {
679: _onkeyup = Util.evalString(expr);
680: return;
681: } else
682: _onkeyupExpr = expr;
683: break;
684:
685: case ONMOUSEDOWN:
686: if (expr != null && expr.isLiteralText()) {
687: _onmousedown = Util.evalString(expr);
688: return;
689: } else
690: _onmousedownExpr = expr;
691: break;
692:
693: case ONMOUSEMOVE:
694: if (expr != null && expr.isLiteralText()) {
695: _onmousemove = Util.evalString(expr);
696: return;
697: } else
698: _onmousemoveExpr = expr;
699: break;
700:
701: case ONMOUSEOUT:
702: if (expr != null && expr.isLiteralText()) {
703: _onmouseout = Util.evalString(expr);
704: return;
705: } else
706: _onmouseoutExpr = expr;
707: break;
708:
709: case ONMOUSEOVER:
710: if (expr != null && expr.isLiteralText()) {
711: _onmouseover = Util.evalString(expr);
712: return;
713: } else
714: _onmouseoverExpr = expr;
715: break;
716:
717: case ONMOUSEUP:
718: if (expr != null && expr.isLiteralText()) {
719: _onmouseup = Util.evalString(expr);
720: return;
721: } else
722: _onmouseupExpr = expr;
723: break;
724:
725: case ONSELECT:
726: if (expr != null && expr.isLiteralText()) {
727: _onselect = Util.evalString(expr);
728: return;
729: } else
730: _onselectExpr = expr;
731: break;
732:
733: case READONLY:
734: if (expr != null && expr.isLiteralText()) {
735: _readonly = Util.evalBoolean(expr);
736: return;
737: } else
738: _readonlyExpr = expr;
739: break;
740:
741: case SIZE:
742: if (expr != null && expr.isLiteralText()) {
743: _size = Util.evalInt(expr);
744: return;
745: } else
746: _sizeExpr = expr;
747: break;
748:
749: case STYLE:
750: if (expr != null && expr.isLiteralText()) {
751: _style = Util.evalString(expr);
752: return;
753: } else
754: _styleExpr = expr;
755: break;
756:
757: case STYLE_CLASS:
758: if (expr != null && expr.isLiteralText()) {
759: _styleClass = Util.evalString(expr);
760: return;
761: } else
762: _styleClassExpr = expr;
763: break;
764:
765: case TABINDEX:
766: if (expr != null && expr.isLiteralText()) {
767: _tabindex = Util.evalString(expr);
768: return;
769: } else
770: _tabindexExpr = expr;
771: break;
772:
773: case TITLE:
774: if (expr != null && expr.isLiteralText()) {
775: _title = Util.evalString(expr);
776: return;
777: } else
778: _titleExpr = expr;
779: break;
780: }
781: }
782:
783: super .setValueExpression(name, expr);
784: }
785:
786: //
787: // state
788: //
789:
790: public Object saveState(FacesContext context) {
791: Object parent = super .saveState(context);
792:
793: return new Object[] { parent,
794:
795: _accesskey, _dir, _disabled, _disabledClass, _enabledClass,
796: _label, _lang,
797:
798: _onblur, _onchange, _onclick, _ondblclick, _onfocus,
799:
800: _onkeydown, _onkeypress, _onkeyup,
801:
802: _onmousedown, _onmousemove, _onmouseout, _onmouseover,
803: _onmouseup,
804:
805: _onselect,
806:
807: _readonly,
808:
809: _size, _style, _styleClass, _tabindex, _title, };
810: }
811:
812: public void restoreState(FacesContext context, Object value) {
813: Object[] state = (Object[]) value;
814:
815: int i = 0;
816:
817: if (state != null)
818: super .restoreState(context, state[i++]);
819:
820: _accesskey = (String) state[i++];
821: _dir = (String) state[i++];
822: _disabled = (Boolean) state[i++];
823: _disabledClass = (String) state[i++];
824: _enabledClass = (String) state[i++];
825: _label = (String) state[i++];
826: _lang = (String) state[i++];
827: _onblur = (String) state[i++];
828: _onchange = (String) state[i++];
829: _onclick = (String) state[i++];
830: _ondblclick = (String) state[i++];
831: _onfocus = (String) state[i++];
832: _onkeydown = (String) state[i++];
833: _onkeypress = (String) state[i++];
834: _onkeyup = (String) state[i++];
835: _onmousedown = (String) state[i++];
836: _onmousemove = (String) state[i++];
837: _onmouseout = (String) state[i++];
838: _onmouseover = (String) state[i++];
839: _onmouseup = (String) state[i++];
840: _onselect = (String) state[i++];
841: _readonly = (Boolean) state[i++];
842: _size = (Integer) state[i++];
843: _style = (String) state[i++];
844: _styleClass = (String) state[i++];
845: _tabindex = (String) state[i++];
846: _title = (String) state[i++];
847: }
848:
849: //
850: // utility
851: //
852:
853: private enum PropEnum {
854: ACCESSKEY, DIR, DISABLED, DISABLED_CLASS, ENABLED_CLASS, LABEL, LANG, ONBLUR, ONCHANGE, ONCLICK, ONDBLCLICK, ONFOCUS, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, ONSELECT, READONLY, SIZE, STYLE, STYLE_CLASS, TABINDEX, TITLE,
855: }
856:
857: static {
858: _propMap.put("accesskey", PropEnum.ACCESSKEY);
859: _propMap.put("dir", PropEnum.DIR);
860: _propMap.put("disabled", PropEnum.DISABLED);
861: _propMap.put("disabledClass", PropEnum.DISABLED_CLASS);
862: _propMap.put("enabledClass", PropEnum.ENABLED_CLASS);
863: _propMap.put("label", PropEnum.LABEL);
864: _propMap.put("lang", PropEnum.LANG);
865: _propMap.put("onblur", PropEnum.ONBLUR);
866: _propMap.put("onchange", PropEnum.ONCHANGE);
867: _propMap.put("onclick", PropEnum.ONCLICK);
868: _propMap.put("ondblclick", PropEnum.ONDBLCLICK);
869: _propMap.put("onfocus", PropEnum.ONFOCUS);
870: _propMap.put("onkeydown", PropEnum.ONKEYDOWN);
871: _propMap.put("onkeypress", PropEnum.ONKEYPRESS);
872: _propMap.put("onkeyup", PropEnum.ONKEYUP);
873: _propMap.put("onmousedown", PropEnum.ONMOUSEDOWN);
874: _propMap.put("onmousemove", PropEnum.ONMOUSEMOVE);
875: _propMap.put("onmouseover", PropEnum.ONMOUSEOVER);
876: _propMap.put("onmouseout", PropEnum.ONMOUSEOUT);
877: _propMap.put("onmouseup", PropEnum.ONMOUSEUP);
878: _propMap.put("onselect", PropEnum.ONSELECT);
879: _propMap.put("readonly", PropEnum.READONLY);
880: _propMap.put("size", PropEnum.SIZE);
881: _propMap.put("style", PropEnum.STYLE);
882: _propMap.put("styleClass", PropEnum.STYLE_CLASS);
883: _propMap.put("tabindex", PropEnum.TABINDEX);
884: _propMap.put("title", PropEnum.TITLE);
885: }
886: }
|