KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icesoft > faces > component > ext > HtmlInputTextarea


1 /*
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * "The contents of this file are subject to the Mozilla Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
11  * License for the specific language governing rights and limitations under
12  * the License.
13  *
14  * The Original Code is ICEfaces 1.5 open source software code, released
15  * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
16  * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
17  * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
18  *
19  * Contributor(s): _____________________.
20  *
21  * Alternatively, the contents of this file may be used under the terms of
22  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
23  * License), in which case the provisions of the LGPL License are
24  * applicable instead of those above. If you wish to allow use of your
25  * version of this file only under the terms of the LGPL License and not to
26  * allow others to use your version of this file under the MPL, indicate
27  * your decision by deleting the provisions above and replace them with
28  * the notice and other provisions required by the LGPL License. If you do
29  * not delete the provisions above, a recipient may use your version of
30  * this file under either the MPL or the LGPL License."
31  *
32  */

33
34 package com.icesoft.faces.component.ext;
35
36 import com.icesoft.faces.component.CSS_DEFAULT;
37 import com.icesoft.faces.component.IceExtended;
38 import com.icesoft.faces.component.ext.taglib.Util;
39 import com.icesoft.faces.context.BridgeFacesContext;
40 import com.icesoft.faces.context.effects.CurrentStyle;
41 import com.icesoft.faces.context.effects.Effect;
42 import com.icesoft.faces.context.effects.JavascriptContext;
43
44 import javax.faces.context.FacesContext;
45 import javax.faces.el.ValueBinding;
46
47 /**
48  * This is an extension of javax.faces.component.html.HtmlInputTextarea, which
49  * provides some additional behavior to this component such as: <ul> <li>default
50  * classes for enabled and disabled state</li> <li>provides partial submit
51  * mechanism</li> <li>changes the component's enabled and rendered state based
52  * on the authentication</li> <li>adds effects to the component</li> <ul>
53  */

54 public class HtmlInputTextarea
55         extends javax.faces.component.html.HtmlInputTextarea
56         implements IceExtended {
57
58     public static final String JavaDoc COMPONENT_TYPE =
59             "com.icesoft.faces.HtmlInputTextarea";
60     public static final String JavaDoc RENDERER_TYPE = "com.icesoft.faces.Textarea";
61     private String JavaDoc styleClass = null;
62     private static final boolean DEFAULT_VISIBLE = true;
63     private Boolean JavaDoc partialSubmit = null;
64     private String JavaDoc enabledOnUserRole = null;
65     private String JavaDoc renderedOnUserRole = null;
66     private Effect effect;
67     private Boolean JavaDoc visible = null;
68
69     private Effect onclickeffect;
70     private Effect ondblclickeffect;
71     private Effect onmousedowneffect;
72     private Effect onmouseupeffect;
73     private Effect onmousemoveeffect;
74     private Effect onmouseovereffect;
75     private Effect onmouseouteffect;
76     private Effect onchangeeffect;
77     private Effect onkeypresseffect;
78     private Effect onkeydowneffect;
79     private Effect onkeyupeffect;
80
81     private CurrentStyle currentStyle;
82
83     public HtmlInputTextarea() {
84         super();
85         setRendererType(RENDERER_TYPE);
86     }
87
88     /**
89      * This method is used to communicate a focus request from the application
90      * to the client browser.
91      */

92     public void requestFocus() {
93         ((BridgeFacesContext) FacesContext.getCurrentInstance())
94                 .setFocusId("null");
95         JavascriptContext.focus(FacesContext.getCurrentInstance(),
96                                 this.getClientId(
97                                         FacesContext.getCurrentInstance()));
98     }
99
100     public void setValueBinding(String JavaDoc s, ValueBinding vb) {
101         if (s != null && s.indexOf("effect") != -1) {
102             // If this is an effect attribute make sure Ice Extras is included
103
JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
104                                          getFacesContext());
105         }
106         super.setValueBinding(s, vb);
107     }
108
109     /**
110      * <p>Set the value of the <code>effect</code> property.</p>
111      */

112     public void setEffect(Effect effect) {
113         this.effect = effect;
114         JavascriptContext
115                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
116     }
117
118     /**
119      * <p>Return the value of the <code>effect</code> property.</p>
120      */

121     public Effect getEffect() {
122         if (effect != null) {
123             return effect;
124         }
125         ValueBinding vb = getValueBinding("effect");
126         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
127     }
128
129     /**
130      * <p>Set the value of the <code>visible</code> property.</p>
131      */

132     public void setVisible(boolean visible) {
133         this.visible = Boolean.valueOf(visible);
134     }
135
136     /**
137      * <p>Return the value of the <code>visible</code> property.</p>
138      */

139     public boolean getVisible() {
140         if (visible != null) {
141             return visible.booleanValue();
142         }
143         ValueBinding vb = getValueBinding("visible");
144         Boolean JavaDoc boolVal =
145                 vb != null ? (Boolean JavaDoc) vb.getValue(getFacesContext()) : null;
146         return boolVal != null ? boolVal.booleanValue() : 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 JavaDoc boolVal =
165                 vb != null ? (Boolean JavaDoc) vb.getValue(getFacesContext()) : null;
166         return boolVal != null ? boolVal.booleanValue() :
167                Util.isParentPartialSubmit(this);
168     }
169
170     /**
171      * <p>Set the value of the <code>enabledOnUserRole</code> property.</p>
172      */

173     public void setEnabledOnUserRole(String JavaDoc enabledOnUserRole) {
174         this.enabledOnUserRole = enabledOnUserRole;
175     }
176
177     /**
178      * <p>Return the value of the <code>enabledOnUserRole</code> property.</p>
179      */

180     public String JavaDoc getEnabledOnUserRole() {
181         if (enabledOnUserRole != null) {
182             return enabledOnUserRole;
183         }
184         ValueBinding vb = getValueBinding("enabledOnUserRole");
185         return vb != null ? (String JavaDoc) vb.getValue(getFacesContext()) : null;
186     }
187
188     /**
189      * <p>Set the value of the <code>renderedOnUserRole</code> property.</p>
190      */

191     public void setRenderedOnUserRole(String JavaDoc renderedOnUserRole) {
192         this.renderedOnUserRole = renderedOnUserRole;
193     }
194
195     /**
196      * <p>Return the value of the <code>renderedOnUserRole</code> property.</p>
197      */

198     public String JavaDoc getRenderedOnUserRole() {
199         if (renderedOnUserRole != null) {
200             return renderedOnUserRole;
201         }
202         ValueBinding vb = getValueBinding("renderedOnUserRole");
203         return vb != null ? (String JavaDoc) vb.getValue(getFacesContext()) : null;
204     }
205
206     /**
207      * <p>Set the value of the <code>styleClass</code> property.</p>
208      */

209     public void setStyleClass(String JavaDoc styleClass) {
210         this.styleClass = styleClass;
211     }
212
213     /**
214      * <p>Return the value of the <code>styleClass</code> property.</p>
215      */

216     public String JavaDoc getStyleClass() {
217         return Util.getQualifiedStyleClass(this,
218                 styleClass,
219                 CSS_DEFAULT.INPUT_TEXT_AREA_DEFAULT_STYLE_CLASS,
220                 "styleClass",
221                 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()) : null;
244     }
245
246     /**
247      * <p>Set the value of the <code>onclickeffect</code> property.</p>
248      */

249     public void setOnclickeffect(Effect onclickeffect) {
250         this.onclickeffect = onclickeffect;
251         JavascriptContext
252                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
253     }
254
255     /**
256      * <p>Return the value of the <code>ondblclickeffect</code> property.</p>
257      */

258     public Effect getOndblclickeffect() {
259         if (ondblclickeffect != null) {
260             return ondblclickeffect;
261         }
262         ValueBinding vb = getValueBinding("ondblclickeffect");
263
264         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
265     }
266
267     /**
268      * <p>Set the value of the <code>ondblclickeffect</code> property.</p>
269      */

270     public void setOndblclickeffect(Effect ondblclickeffect) {
271         this.ondblclickeffect = ondblclickeffect;
272         JavascriptContext
273                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
274     }
275
276     /**
277      * <p>Return the value of the <code>onmousedowneffect</code> property.</p>
278      */

279     public Effect getOnmousedowneffect() {
280         if (onmousedowneffect != null) {
281             return onmousedowneffect;
282         }
283         ValueBinding vb = getValueBinding("onmousedowneffect");
284
285         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
286     }
287
288     /**
289      * <p>Set the value of the <code>onmousedowneffect</code> property.</p>
290      */

291     public void setOnmousedowneffect(Effect onmousedowneffect) {
292         this.onmousedowneffect = onmousedowneffect;
293         JavascriptContext
294                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
295     }
296
297     /**
298      * <p>Return the value of the <code>onmouseupeffect</code> property.</p>
299      */

300     public Effect getOnmouseupeffect() {
301         if (onmouseupeffect != null) {
302             return onmouseupeffect;
303         }
304         ValueBinding vb = getValueBinding("onmouseupeffect");
305
306         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
307     }
308
309     /**
310      * <p>Set the value of the <code>onmouseupeffect</code> property.</p>
311      */

312     public void setOnmouseupeffect(Effect onmouseupeffect) {
313         this.onmouseupeffect = onmouseupeffect;
314         JavascriptContext
315                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
316     }
317
318     /**
319      * <p>Return the value of the <code>onmousemoveeffect</code> property.</p>
320      */

321     public Effect getOnmousemoveeffect() {
322         if (onmousemoveeffect != null) {
323             return onmousemoveeffect;
324         }
325         ValueBinding vb = getValueBinding("onmousemoveeffect");
326
327         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
328     }
329
330     /**
331      * <p>Set the value of the <code>onmousemoveeffect</code> property.</p>
332      */

333     public void setOnmousemoveeffect(Effect onmousemoveeffect) {
334         this.onmousemoveeffect = onmousemoveeffect;
335         JavascriptContext
336                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
337     }
338
339     /**
340      * <p>Return the value of the <code>onmouseovereffect</code> property.</p>
341      */

342     public Effect getOnmouseovereffect() {
343         if (onmouseovereffect != null) {
344             return onmouseovereffect;
345         }
346         ValueBinding vb = getValueBinding("onmouseovereffect");
347
348         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
349     }
350
351     /**
352      * <p>Set the value of the <code>onmouseovereffect</code> property.</p>
353      */

354     public void setOnmouseovereffect(Effect onmouseovereffect) {
355         this.onmouseovereffect = onmouseovereffect;
356         JavascriptContext
357                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
358     }
359
360     /**
361      * <p>Return the value of the <code>onmouseouteffect</code> property.</p>
362      */

363     public Effect getOnmouseouteffect() {
364         if (onmouseouteffect != null) {
365             return onmouseouteffect;
366         }
367         ValueBinding vb = getValueBinding("onmouseouteffect");
368
369         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
370     }
371
372     /**
373      * <p>Set the value of the <code>onmouseouteffect</code> property.</p>
374      */

375     public void setOnmouseouteffect(Effect onmouseouteffect) {
376         this.onmouseouteffect = onmouseouteffect;
377         JavascriptContext
378                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
379     }
380
381     /**
382      * <p>Return the value of the <code>onchangeeffect</code> property.</p>
383      */

384     public Effect getOnchangeeffect() {
385         if (onchangeeffect != null) {
386             return onchangeeffect;
387         }
388         ValueBinding vb = getValueBinding("onchangeeffect");
389
390         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
391     }
392
393     /**
394      * <p>Set the value of the <code>onchangeeffect</code> property.</p>
395      */

396     public void setOnchangeeffect(Effect onchangeeffect) {
397         this.onchangeeffect = onchangeeffect;
398         JavascriptContext
399                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
400     }
401
402
403     /**
404      * <p>Return the value of the <code>onkeypresseffect</code> property.</p>
405      */

406     public Effect getOnkeypresseffect() {
407         if (onkeypresseffect != null) {
408             return onkeypresseffect;
409         }
410         ValueBinding vb = getValueBinding("onkeypresseffect");
411
412         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
413     }
414
415     /**
416      * <p>Set the value of the <code>onkeypresseffect</code> property.</p>
417      */

418     public void setOnkeypresseffect(Effect onkeypresseffect) {
419         this.onkeypresseffect = onkeypresseffect;
420         JavascriptContext
421                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
422     }
423
424     /**
425      * <p>Return the value of the <code>onkeydowneffect</code> property.</p>
426      */

427     public Effect getOnkeydowneffect() {
428         if (onkeydowneffect != null) {
429             return onkeydowneffect;
430         }
431         ValueBinding vb = getValueBinding("onkeydowneffect");
432
433         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
434     }
435
436     /**
437      * <p>Set the value of the <code>onkeydowneffect</code> property.</p>
438      */

439     public void setOnkeydowneffect(Effect onkeydowneffect) {
440         this.onkeydowneffect = onkeydowneffect;
441         JavascriptContext
442                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
443     }
444
445     /**
446      * <p>Return the value of the <code>onkeyupeffect</code> property.</p>
447      */

448     public Effect getOnkeyupeffect() {
449         if (onkeyupeffect != null) {
450             return onkeyupeffect;
451         }
452         ValueBinding vb = getValueBinding("onkeyupeffect");
453
454         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
455     }
456
457     /**
458      * <p>Set the value of the <code>onkeyupeffect</code> property.</p>
459      */

460     public void setOnkeyupeffect(Effect onkeyupeffect) {
461         this.onkeyupeffect = onkeyupeffect;
462         JavascriptContext
463                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
464     }
465
466     /**
467      * <p>Return the value of the <code>disabled</code> property.</p>
468      */

469     public boolean isDisabled() {
470         if (!Util.isEnabledOnUserRole(this)) {
471             return true;
472         } else {
473             return super.isDisabled();
474         }
475     }
476
477     /**
478      * <p>Return the value of the <code>currentStyle</code> property.</p>
479      */

480     public CurrentStyle getCurrentStyle() {
481         return currentStyle;
482     }
483
484     /**
485      * <p>Set the value of the <code>currentStyle</code> property.</p>
486      */

487     public void setCurrentStyle(CurrentStyle currentStyle) {
488         this.currentStyle = currentStyle;
489     }
490
491     private String JavaDoc autocomplete;
492
493     /**
494      * <p>Set the value of the <code>autocomplete</code> property.</p>
495      */

496     public void setAutocomplete(String JavaDoc autocomplete) {
497         this.autocomplete = autocomplete;
498     }
499
500     /**
501      * <p>Return the value of the <code>autocomplete</code> property.</p>
502      */

503     public String JavaDoc getAutocomplete() {
504         if (autocomplete != null) {
505             return autocomplete;
506         }
507         ValueBinding vb = getValueBinding("autocomplete");
508         return vb != null ? (String JavaDoc) vb.getValue(getFacesContext()) : null;
509     }
510
511     /**
512      * <p>Gets the state of the instance as a <code>Serializable</code>
513      * Object.</p>
514      */

515     public Object JavaDoc saveState(FacesContext context) {
516         Object JavaDoc values[] = new Object JavaDoc[22];
517         values[0] = super.saveState(context);
518         values[1] = partialSubmit;
519         values[2] = enabledOnUserRole;
520         values[3] = renderedOnUserRole;
521         values[4] = styleClass;
522         values[5] = effect;
523         values[6] = onclickeffect;
524         values[7] = ondblclickeffect;
525         values[8] = onmousedowneffect;
526         values[9] = onmouseupeffect;
527         values[10] = onmousemoveeffect;
528         values[11] = onmouseovereffect;
529         values[12] = onmouseouteffect;
530         values[13] = onchangeeffect;
531         values[16] = onkeypresseffect;
532         values[17] = onkeydowneffect;
533         values[18] = onkeyupeffect;
534         values[19] = currentStyle;
535         values[20] = visible;
536         values[21] = autocomplete;
537         return ((Object JavaDoc) (values));
538     }
539
540     /**
541      * <p>Perform any processing required to restore the state from the entries
542      * in the state Object.</p>
543      */

544     public void restoreState(FacesContext context, Object JavaDoc state) {
545         Object JavaDoc values[] = (Object JavaDoc[]) state;
546         super.restoreState(context, values[0]);
547         partialSubmit = (Boolean JavaDoc) values[1];
548         enabledOnUserRole = (String JavaDoc) values[2];
549         renderedOnUserRole = (String JavaDoc) values[3];
550         styleClass = (String JavaDoc) values[4];
551         effect = (Effect) values[5];
552         onclickeffect = (Effect) values[6];
553         ondblclickeffect = (Effect) values[7];
554         onmousedowneffect = (Effect) values[8];
555         onmouseupeffect = (Effect) values[9];
556         onmousemoveeffect = (Effect) values[10];
557         onmouseovereffect = (Effect) values[11];
558         onmouseouteffect = (Effect) values[12];
559         onchangeeffect = (Effect) values[13];
560         onkeypresseffect = (Effect) values[16];
561         onkeydowneffect = (Effect) values[17];
562         onkeyupeffect = (Effect) values[18];
563         currentStyle = (CurrentStyle) values[19];
564         visible = (Boolean JavaDoc) values[20];
565         autocomplete = (String JavaDoc) values[21];
566     }
567 }
568    
569
570   
Popular Tags