001: /*
002: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
003: *
004: * "The contents of this file are subject to the Mozilla Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License at
007: * http://www.mozilla.org/MPL/
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
011: * License for the specific language governing rights and limitations under
012: * the License.
013: *
014: * The Original Code is ICEfaces 1.5 open source software code, released
015: * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
016: * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
017: * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
018: *
019: * Contributor(s): _____________________.
020: *
021: * Alternatively, the contents of this file may be used under the terms of
022: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
023: * License), in which case the provisions of the LGPL License are
024: * applicable instead of those above. If you wish to allow use of your
025: * version of this file only under the terms of the LGPL License and not to
026: * allow others to use your version of this file under the MPL, indicate
027: * your decision by deleting the provisions above and replace them with
028: * the notice and other provisions required by the LGPL License. If you do
029: * not delete the provisions above, a recipient may use your version of
030: * this file under either the MPL or the LGPL License."
031: *
032: */
033:
034: package com.icesoft.faces.component.ext;
035:
036: import com.icesoft.faces.component.CSS_DEFAULT;
037: import com.icesoft.faces.component.IceExtended;
038: import com.icesoft.faces.component.ext.taglib.Util;
039: import com.icesoft.faces.context.BridgeFacesContext;
040: import com.icesoft.faces.context.effects.CurrentStyle;
041: import com.icesoft.faces.context.effects.Effect;
042: import com.icesoft.faces.context.effects.JavascriptContext;
043:
044: import javax.faces.context.FacesContext;
045: import javax.faces.el.ValueBinding;
046:
047: /**
048: * This is an extension of javax.faces.component.html.HtmlInputTextarea, which
049: * provides some additional behavior to this component such as: <ul> <li>default
050: * classes for enabled and disabled state</li> <li>provides partial submit
051: * mechanism</li> <li>changes the component's enabled and rendered state based
052: * on the authentication</li> <li>adds effects to the component</li> <ul>
053: */
054: public class HtmlInputTextarea extends
055: javax.faces.component.html.HtmlInputTextarea implements
056: IceExtended {
057:
058: public static final String COMPONENT_TYPE = "com.icesoft.faces.HtmlInputTextarea";
059: public static final String RENDERER_TYPE = "com.icesoft.faces.Textarea";
060: private String styleClass = null;
061: private static final boolean DEFAULT_VISIBLE = true;
062: private Boolean partialSubmit = null;
063: private String enabledOnUserRole = null;
064: private String renderedOnUserRole = null;
065: private Effect effect;
066: private Boolean visible = null;
067:
068: private Effect onclickeffect;
069: private Effect ondblclickeffect;
070: private Effect onmousedowneffect;
071: private Effect onmouseupeffect;
072: private Effect onmousemoveeffect;
073: private Effect onmouseovereffect;
074: private Effect onmouseouteffect;
075: private Effect onchangeeffect;
076: private Effect onkeypresseffect;
077: private Effect onkeydowneffect;
078: private Effect onkeyupeffect;
079:
080: private CurrentStyle currentStyle;
081:
082: public HtmlInputTextarea() {
083: super ();
084: setRendererType(RENDERER_TYPE);
085: }
086:
087: /**
088: * This method is used to communicate a focus request from the application
089: * to the client browser.
090: */
091: public void requestFocus() {
092: ((BridgeFacesContext) FacesContext.getCurrentInstance())
093: .setFocusId("null");
094: JavascriptContext.focus(FacesContext.getCurrentInstance(), this
095: .getClientId(FacesContext.getCurrentInstance()));
096: }
097:
098: public void setValueBinding(String s, ValueBinding vb) {
099: if (s != null && s.indexOf("effect") != -1) {
100: // If this is an effect attribute make sure Ice Extras is included
101: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
102: getFacesContext());
103: }
104: super .setValueBinding(s, vb);
105: }
106:
107: /**
108: * <p>Set the value of the <code>effect</code> property.</p>
109: */
110: public void setEffect(Effect effect) {
111: this .effect = effect;
112: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
113: getFacesContext());
114: }
115:
116: /**
117: * <p>Return the value of the <code>effect</code> property.</p>
118: */
119: public Effect getEffect() {
120: if (effect != null) {
121: return effect;
122: }
123: ValueBinding vb = getValueBinding("effect");
124: return vb != null ? (Effect) vb.getValue(getFacesContext())
125: : null;
126: }
127:
128: /**
129: * <p>Set the value of the <code>visible</code> property.</p>
130: */
131: public void setVisible(boolean visible) {
132: this .visible = Boolean.valueOf(visible);
133: }
134:
135: /**
136: * <p>Return the value of the <code>visible</code> property.</p>
137: */
138: public boolean getVisible() {
139: if (visible != null) {
140: return visible.booleanValue();
141: }
142: ValueBinding vb = getValueBinding("visible");
143: Boolean boolVal = vb != null ? (Boolean) vb
144: .getValue(getFacesContext()) : null;
145: return boolVal != null ? boolVal.booleanValue()
146: : DEFAULT_VISIBLE;
147: }
148:
149: /**
150: * <p>Set the value of the <code>partialSubmit</code> property.</p>
151: */
152: public void setPartialSubmit(boolean partialSubmit) {
153: this .partialSubmit = Boolean.valueOf(partialSubmit);
154: }
155:
156: /**
157: * <p>Return the value of the <code>partialSubmit</code> property.</p>
158: */
159: public boolean getPartialSubmit() {
160: if (partialSubmit != null) {
161: return partialSubmit.booleanValue();
162: }
163: ValueBinding vb = getValueBinding("partialSubmit");
164: Boolean boolVal = vb != null ? (Boolean) vb
165: .getValue(getFacesContext()) : null;
166: return boolVal != null ? boolVal.booleanValue() : Util
167: .isParentPartialSubmit(this );
168: }
169:
170: /**
171: * <p>Set the value of the <code>enabledOnUserRole</code> property.</p>
172: */
173: public void setEnabledOnUserRole(String enabledOnUserRole) {
174: this .enabledOnUserRole = enabledOnUserRole;
175: }
176:
177: /**
178: * <p>Return the value of the <code>enabledOnUserRole</code> property.</p>
179: */
180: public String getEnabledOnUserRole() {
181: if (enabledOnUserRole != null) {
182: return enabledOnUserRole;
183: }
184: ValueBinding vb = getValueBinding("enabledOnUserRole");
185: return vb != null ? (String) vb.getValue(getFacesContext())
186: : null;
187: }
188:
189: /**
190: * <p>Set the value of the <code>renderedOnUserRole</code> property.</p>
191: */
192: public void setRenderedOnUserRole(String renderedOnUserRole) {
193: this .renderedOnUserRole = renderedOnUserRole;
194: }
195:
196: /**
197: * <p>Return the value of the <code>renderedOnUserRole</code> property.</p>
198: */
199: public String getRenderedOnUserRole() {
200: if (renderedOnUserRole != null) {
201: return renderedOnUserRole;
202: }
203: ValueBinding vb = getValueBinding("renderedOnUserRole");
204: return vb != null ? (String) vb.getValue(getFacesContext())
205: : null;
206: }
207:
208: /**
209: * <p>Set the value of the <code>styleClass</code> property.</p>
210: */
211: public void setStyleClass(String styleClass) {
212: this .styleClass = styleClass;
213: }
214:
215: /**
216: * <p>Return the value of the <code>styleClass</code> property.</p>
217: */
218: public String getStyleClass() {
219: return Util.getQualifiedStyleClass(this , styleClass,
220: CSS_DEFAULT.INPUT_TEXT_AREA_DEFAULT_STYLE_CLASS,
221: "styleClass", isDisabled());
222: }
223:
224: /**
225: * <p>Return the value of the <code>rendered</code> property.</p>
226: */
227: public boolean isRendered() {
228: if (!Util.isRenderedOnUserRole(this )) {
229: return false;
230: }
231: return super .isRendered();
232: }
233:
234: /**
235: * <p>Return the value of the <code>onclickeffect</code> property.</p>
236: */
237: public Effect getOnclickeffect() {
238: if (onclickeffect != null) {
239: return onclickeffect;
240: }
241: ValueBinding vb = getValueBinding("onclickeffect");
242:
243: return vb != null ? (Effect) vb.getValue(getFacesContext())
244: : null;
245: }
246:
247: /**
248: * <p>Set the value of the <code>onclickeffect</code> property.</p>
249: */
250: public void setOnclickeffect(Effect onclickeffect) {
251: this .onclickeffect = onclickeffect;
252: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
253: getFacesContext());
254: }
255:
256: /**
257: * <p>Return the value of the <code>ondblclickeffect</code> property.</p>
258: */
259: public Effect getOndblclickeffect() {
260: if (ondblclickeffect != null) {
261: return ondblclickeffect;
262: }
263: ValueBinding vb = getValueBinding("ondblclickeffect");
264:
265: return vb != null ? (Effect) vb.getValue(getFacesContext())
266: : null;
267: }
268:
269: /**
270: * <p>Set the value of the <code>ondblclickeffect</code> property.</p>
271: */
272: public void setOndblclickeffect(Effect ondblclickeffect) {
273: this .ondblclickeffect = ondblclickeffect;
274: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
275: getFacesContext());
276: }
277:
278: /**
279: * <p>Return the value of the <code>onmousedowneffect</code> property.</p>
280: */
281: public Effect getOnmousedowneffect() {
282: if (onmousedowneffect != null) {
283: return onmousedowneffect;
284: }
285: ValueBinding vb = getValueBinding("onmousedowneffect");
286:
287: return vb != null ? (Effect) vb.getValue(getFacesContext())
288: : null;
289: }
290:
291: /**
292: * <p>Set the value of the <code>onmousedowneffect</code> property.</p>
293: */
294: public void setOnmousedowneffect(Effect onmousedowneffect) {
295: this .onmousedowneffect = onmousedowneffect;
296: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
297: getFacesContext());
298: }
299:
300: /**
301: * <p>Return the value of the <code>onmouseupeffect</code> property.</p>
302: */
303: public Effect getOnmouseupeffect() {
304: if (onmouseupeffect != null) {
305: return onmouseupeffect;
306: }
307: ValueBinding vb = getValueBinding("onmouseupeffect");
308:
309: return vb != null ? (Effect) vb.getValue(getFacesContext())
310: : null;
311: }
312:
313: /**
314: * <p>Set the value of the <code>onmouseupeffect</code> property.</p>
315: */
316: public void setOnmouseupeffect(Effect onmouseupeffect) {
317: this .onmouseupeffect = onmouseupeffect;
318: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
319: getFacesContext());
320: }
321:
322: /**
323: * <p>Return the value of the <code>onmousemoveeffect</code> property.</p>
324: */
325: public Effect getOnmousemoveeffect() {
326: if (onmousemoveeffect != null) {
327: return onmousemoveeffect;
328: }
329: ValueBinding vb = getValueBinding("onmousemoveeffect");
330:
331: return vb != null ? (Effect) vb.getValue(getFacesContext())
332: : null;
333: }
334:
335: /**
336: * <p>Set the value of the <code>onmousemoveeffect</code> property.</p>
337: */
338: public void setOnmousemoveeffect(Effect onmousemoveeffect) {
339: this .onmousemoveeffect = onmousemoveeffect;
340: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
341: getFacesContext());
342: }
343:
344: /**
345: * <p>Return the value of the <code>onmouseovereffect</code> property.</p>
346: */
347: public Effect getOnmouseovereffect() {
348: if (onmouseovereffect != null) {
349: return onmouseovereffect;
350: }
351: ValueBinding vb = getValueBinding("onmouseovereffect");
352:
353: return vb != null ? (Effect) vb.getValue(getFacesContext())
354: : null;
355: }
356:
357: /**
358: * <p>Set the value of the <code>onmouseovereffect</code> property.</p>
359: */
360: public void setOnmouseovereffect(Effect onmouseovereffect) {
361: this .onmouseovereffect = onmouseovereffect;
362: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
363: getFacesContext());
364: }
365:
366: /**
367: * <p>Return the value of the <code>onmouseouteffect</code> property.</p>
368: */
369: public Effect getOnmouseouteffect() {
370: if (onmouseouteffect != null) {
371: return onmouseouteffect;
372: }
373: ValueBinding vb = getValueBinding("onmouseouteffect");
374:
375: return vb != null ? (Effect) vb.getValue(getFacesContext())
376: : null;
377: }
378:
379: /**
380: * <p>Set the value of the <code>onmouseouteffect</code> property.</p>
381: */
382: public void setOnmouseouteffect(Effect onmouseouteffect) {
383: this .onmouseouteffect = onmouseouteffect;
384: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
385: getFacesContext());
386: }
387:
388: /**
389: * <p>Return the value of the <code>onchangeeffect</code> property.</p>
390: */
391: public Effect getOnchangeeffect() {
392: if (onchangeeffect != null) {
393: return onchangeeffect;
394: }
395: ValueBinding vb = getValueBinding("onchangeeffect");
396:
397: return vb != null ? (Effect) vb.getValue(getFacesContext())
398: : null;
399: }
400:
401: /**
402: * <p>Set the value of the <code>onchangeeffect</code> property.</p>
403: */
404: public void setOnchangeeffect(Effect onchangeeffect) {
405: this .onchangeeffect = onchangeeffect;
406: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
407: getFacesContext());
408: }
409:
410: /**
411: * <p>Return the value of the <code>onkeypresseffect</code> property.</p>
412: */
413: public Effect getOnkeypresseffect() {
414: if (onkeypresseffect != null) {
415: return onkeypresseffect;
416: }
417: ValueBinding vb = getValueBinding("onkeypresseffect");
418:
419: return vb != null ? (Effect) vb.getValue(getFacesContext())
420: : null;
421: }
422:
423: /**
424: * <p>Set the value of the <code>onkeypresseffect</code> property.</p>
425: */
426: public void setOnkeypresseffect(Effect onkeypresseffect) {
427: this .onkeypresseffect = onkeypresseffect;
428: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
429: getFacesContext());
430: }
431:
432: /**
433: * <p>Return the value of the <code>onkeydowneffect</code> property.</p>
434: */
435: public Effect getOnkeydowneffect() {
436: if (onkeydowneffect != null) {
437: return onkeydowneffect;
438: }
439: ValueBinding vb = getValueBinding("onkeydowneffect");
440:
441: return vb != null ? (Effect) vb.getValue(getFacesContext())
442: : null;
443: }
444:
445: /**
446: * <p>Set the value of the <code>onkeydowneffect</code> property.</p>
447: */
448: public void setOnkeydowneffect(Effect onkeydowneffect) {
449: this .onkeydowneffect = onkeydowneffect;
450: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
451: getFacesContext());
452: }
453:
454: /**
455: * <p>Return the value of the <code>onkeyupeffect</code> property.</p>
456: */
457: public Effect getOnkeyupeffect() {
458: if (onkeyupeffect != null) {
459: return onkeyupeffect;
460: }
461: ValueBinding vb = getValueBinding("onkeyupeffect");
462:
463: return vb != null ? (Effect) vb.getValue(getFacesContext())
464: : null;
465: }
466:
467: /**
468: * <p>Set the value of the <code>onkeyupeffect</code> property.</p>
469: */
470: public void setOnkeyupeffect(Effect onkeyupeffect) {
471: this .onkeyupeffect = onkeyupeffect;
472: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
473: getFacesContext());
474: }
475:
476: /**
477: * <p>Return the value of the <code>disabled</code> property.</p>
478: */
479: public boolean isDisabled() {
480: if (!Util.isEnabledOnUserRole(this )) {
481: return true;
482: } else {
483: return super .isDisabled();
484: }
485: }
486:
487: /**
488: * <p>Return the value of the <code>currentStyle</code> property.</p>
489: */
490: public CurrentStyle getCurrentStyle() {
491: return currentStyle;
492: }
493:
494: /**
495: * <p>Set the value of the <code>currentStyle</code> property.</p>
496: */
497: public void setCurrentStyle(CurrentStyle currentStyle) {
498: this .currentStyle = currentStyle;
499: }
500:
501: private String autocomplete;
502:
503: /**
504: * <p>Set the value of the <code>autocomplete</code> property.</p>
505: */
506: public void setAutocomplete(String autocomplete) {
507: this .autocomplete = autocomplete;
508: }
509:
510: /**
511: * <p>Return the value of the <code>autocomplete</code> property.</p>
512: */
513: public String getAutocomplete() {
514: if (autocomplete != null) {
515: return autocomplete;
516: }
517: ValueBinding vb = getValueBinding("autocomplete");
518: return vb != null ? (String) vb.getValue(getFacesContext())
519: : null;
520: }
521:
522: /**
523: * <p>Gets the state of the instance as a <code>Serializable</code>
524: * Object.</p>
525: */
526: public Object saveState(FacesContext context) {
527: Object values[] = new Object[22];
528: values[0] = super .saveState(context);
529: values[1] = partialSubmit;
530: values[2] = enabledOnUserRole;
531: values[3] = renderedOnUserRole;
532: values[4] = styleClass;
533: values[5] = effect;
534: values[6] = onclickeffect;
535: values[7] = ondblclickeffect;
536: values[8] = onmousedowneffect;
537: values[9] = onmouseupeffect;
538: values[10] = onmousemoveeffect;
539: values[11] = onmouseovereffect;
540: values[12] = onmouseouteffect;
541: values[13] = onchangeeffect;
542: values[16] = onkeypresseffect;
543: values[17] = onkeydowneffect;
544: values[18] = onkeyupeffect;
545: values[19] = currentStyle;
546: values[20] = visible;
547: values[21] = autocomplete;
548: return ((Object) (values));
549: }
550:
551: /**
552: * <p>Perform any processing required to restore the state from the entries
553: * in the state Object.</p>
554: */
555: public void restoreState(FacesContext context, Object state) {
556: Object values[] = (Object[]) state;
557: super .restoreState(context, values[0]);
558: partialSubmit = (Boolean) values[1];
559: enabledOnUserRole = (String) values[2];
560: renderedOnUserRole = (String) values[3];
561: styleClass = (String) values[4];
562: effect = (Effect) values[5];
563: onclickeffect = (Effect) values[6];
564: ondblclickeffect = (Effect) values[7];
565: onmousedowneffect = (Effect) values[8];
566: onmouseupeffect = (Effect) values[9];
567: onmousemoveeffect = (Effect) values[10];
568: onmouseovereffect = (Effect) values[11];
569: onmouseouteffect = (Effect) values[12];
570: onchangeeffect = (Effect) values[13];
571: onkeypresseffect = (Effect) values[16];
572: onkeydowneffect = (Effect) values[17];
573: onkeyupeffect = (Effect) values[18];
574: currentStyle = (CurrentStyle) values[19];
575: visible = (Boolean) values[20];
576: autocomplete = (String) values[21];
577: }
578: }
|