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