KickJava   Java API By Example, From Geeks To Geeks.

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


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.HtmlSelectManyListbox,
49  * which provides some additional behavior to this component such as: <ul>
50  * <li>default classes for enabled and disabled state</li> <li>provides partial
51  * submit mechanism</li> <li>changes the component's enabled and rendered state
52  * based on the authentication</li> <li>adds effects to the component</li> <ul>
53  */

54 public class HtmlSelectManyListbox
55         extends javax.faces.component.html.HtmlSelectManyListbox
56         implements IceExtended {
57
58     public static final String JavaDoc COMPONENT_TYPE =
59             "com.icesoft.faces.HtmlSelectManyListbox";
60     public static final String JavaDoc RENDERER_TYPE = "com.icesoft.faces.Listbox";
61     private static final boolean DEFAULT_VISIBLE = true;
62     private String JavaDoc styleClass = null;
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
77     private Effect onkeypresseffect;
78     private Effect onkeydowneffect;
79     private Effect onkeyupeffect;
80
81     private CurrentStyle currentStyle;
82
83     private Effect onchangeeffect;
84
85     public HtmlSelectManyListbox() {
86         super();
87         setRendererType(RENDERER_TYPE);
88     }
89
90     /**
91      * This method is used to communicate a focus request from the application
92      * to the client browser.
93      */

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

114     public void setVisible(boolean visible) {
115         this.visible = Boolean.valueOf(visible);
116     }
117
118     /**
119      * <p>Return the value of the <code>visible</code> property.</p>
120      */

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

134     public void setEffect(Effect effect) {
135         this.effect = effect;
136         JavascriptContext
137                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
138     }
139
140     /**
141      * <p>Return the value of the <code>effect</code> property.</p>
142      */

143     public Effect getEffect() {
144         if (effect != null) {
145             return effect;
146         }
147         ValueBinding vb = getValueBinding("effect");
148         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
149     }
150
151     /**
152      * <p>Set the value of the <code>partialSubmit</code> property.</p>
153      */

154     public void setPartialSubmit(boolean partialSubmit) {
155         this.partialSubmit = Boolean.valueOf(partialSubmit);
156     }
157
158     /**
159      * <p>Return the value of the <code>partialSubmit</code> property.</p>
160      */

161     public boolean getPartialSubmit() {
162         if (partialSubmit != null) {
163             return partialSubmit.booleanValue();
164         }
165         ValueBinding vb = getValueBinding("partialSubmit");
166         Boolean JavaDoc boolVal =
167                 vb != null ? (Boolean JavaDoc) vb.getValue(getFacesContext()) : null;
168         return boolVal != null ? boolVal.booleanValue() :
169                Util.isParentPartialSubmit(this);
170     }
171
172     /**
173      * <p>Set the value of the <code>enabledOnUserRole</code> property.</p>
174      */

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

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

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

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

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

218     public String JavaDoc getStyleClass() {
219         return Util.getQualifiedStyleClass(this,
220                 styleClass,
221                 CSS_DEFAULT.SELECT_MANY_LISTBOX_DEFAULT_STYLE_CLASS,
222                 "styleClass",
223                 isDisabled());
224     }
225
226     /**
227      * <p>Return the value of the <code>rendered</code> property.</p>
228      */

229     public boolean isRendered() {
230         if (!Util.isRenderedOnUserRole(this)) {
231             return false;
232         }
233         return super.isRendered();
234     }
235
236     /**
237      * <p>Return the value of the <code>disabled</code> property.</p>
238      */

239     public boolean isDisabled() {
240         if (!Util.isEnabledOnUserRole(this)) {
241             return true;
242         } else {
243             return super.isDisabled();
244         }
245     }
246
247
248     /**
249      * <p>Return the value of the <code>onchangeeffect</code> property.</p>
250      */

251     public Effect getOnchangeeffect() {
252         if (onchangeeffect != null) {
253             return onchangeeffect;
254         }
255         ValueBinding vb = getValueBinding("onchangeeffect");
256
257         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
258     }
259
260     /**
261      * <p>Set the value of the <code>onchangeeffect</code> property.</p>
262      */

263     public void setOnchangeeffect(Effect onchangeeffect) {
264         this.onchangeeffect = onchangeeffect;
265         JavascriptContext
266                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
267     }
268
269
270     /**
271      * <p>Return the value of the <code>currentStyle</code> property.</p>
272      */

273     public CurrentStyle getCurrentStyle() {
274         return currentStyle;
275     }
276
277     /**
278      * <p>Set the value of the <code>currentStyle</code> property.</p>
279      */

280     public void setCurrentStyle(CurrentStyle currentStyle) {
281         this.currentStyle = currentStyle;
282     }
283
284     /**
285      * <p>Set the value of the <code>onclickeffect</code> property.</p>
286      */

287     public void setOnclickeffect(Effect onclickeffect) {
288         this.onclickeffect = onclickeffect;
289         JavascriptContext
290                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
291     }
292
293     /**
294      * <p>Return the value of the <code>ondblclickeffect</code> property.</p>
295      */

296     public Effect getOndblclickeffect() {
297         if (ondblclickeffect != null) {
298             return ondblclickeffect;
299         }
300         ValueBinding vb = getValueBinding("ondblclickeffect");
301
302         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
303     }
304
305     /**
306      * <p>Set the value of the <code>ondblclickeffect</code> property.</p>
307      */

308     public void setOndblclickeffect(Effect ondblclickeffect) {
309         this.ondblclickeffect = ondblclickeffect;
310         JavascriptContext
311                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
312     }
313
314     /**
315      * <p>Return the value of the <code>onmousedowneffect</code> property.</p>
316      */

317     public Effect getOnmousedowneffect() {
318         if (onmousedowneffect != null) {
319             return onmousedowneffect;
320         }
321         ValueBinding vb = getValueBinding("onmousedowneffect");
322
323         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
324     }
325
326     /**
327      * <p>Set the value of the <code>onmousedowneffect</code> property.</p>
328      */

329     public void setOnmousedowneffect(Effect onmousedowneffect) {
330         this.onmousedowneffect = onmousedowneffect;
331         JavascriptContext
332                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
333     }
334
335     /**
336      * <p>Return the value of the <code>onmouseupeffect</code> property.</p>
337      */

338     public Effect getOnmouseupeffect() {
339         if (onmouseupeffect != null) {
340             return onmouseupeffect;
341         }
342         ValueBinding vb = getValueBinding("onmouseupeffect");
343
344         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
345     }
346
347     /**
348      * <p>Set the value of the <code>onmouseupeffect</code> property.</p>
349      */

350     public void setOnmouseupeffect(Effect onmouseupeffect) {
351         this.onmouseupeffect = onmouseupeffect;
352         JavascriptContext
353                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
354     }
355
356     /**
357      * <p>Return the value of the <code>onmousemoveeffect</code> property.</p>
358      */

359     public Effect getOnmousemoveeffect() {
360         if (onmousemoveeffect != null) {
361             return onmousemoveeffect;
362         }
363         ValueBinding vb = getValueBinding("onmousemoveeffect");
364
365         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
366     }
367
368     /**
369      * <p>Set the value of the <code>onmousemoveeffect</code> property.</p>
370      */

371     public void setOnmousemoveeffect(Effect onmousemoveeffect) {
372         this.onmousemoveeffect = onmousemoveeffect;
373         JavascriptContext
374                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
375     }
376
377     /**
378      * <p>Return the value of the <code>onmouseovereffect</code> property.</p>
379      */

380     public Effect getOnmouseovereffect() {
381         if (onmouseovereffect != null) {
382             return onmouseovereffect;
383         }
384         ValueBinding vb = getValueBinding("onmouseovereffect");
385
386         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
387     }
388
389     /**
390      * <p>Set the value of the <code>onmouseovereffect</code> property.</p>
391      */

392     public void setOnmouseovereffect(Effect onmouseovereffect) {
393         this.onmouseovereffect = onmouseovereffect;
394         JavascriptContext
395                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
396     }
397
398     /**
399      * <p>Return the value of the <code>onmouseouteffect</code> property.</p>
400      */

401     public Effect getOnmouseouteffect() {
402         if (onmouseouteffect != null) {
403             return onmouseouteffect;
404         }
405         ValueBinding vb = getValueBinding("onmouseouteffect");
406
407         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
408     }
409
410     /**
411      * <p>Set the value of the <code>onmouseouteffect</code> property.</p>
412      */

413     public void setOnmouseouteffect(Effect onmouseouteffect) {
414         this.onmouseouteffect = onmouseouteffect;
415         JavascriptContext
416                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
417     }
418
419
420     /**
421      * <p>Return the value of the <code>onkeypresseffect</code> property.</p>
422      */

423     public Effect getOnkeypresseffect() {
424         if (onkeypresseffect != null) {
425             return onkeypresseffect;
426         }
427         ValueBinding vb = getValueBinding("onkeypresseffect");
428
429         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
430     }
431
432     /**
433      * <p>Set the value of the <code>onkeypresseffect</code> property.</p>
434      */

435     public void setOnkeypresseffect(Effect onkeypresseffect) {
436         this.onkeypresseffect = onkeypresseffect;
437         JavascriptContext
438                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
439     }
440
441     /**
442      * <p>Return the value of the <code>onkeydowneffect</code> property.</p>
443      */

444     public Effect getOnkeydowneffect() {
445         if (onkeydowneffect != null) {
446             return onkeydowneffect;
447         }
448         ValueBinding vb = getValueBinding("onkeydowneffect");
449
450         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
451     }
452
453     /**
454      * <p>Set the value of the <code>onkeydowneffect</code> property.</p>
455      */

456     public void setOnkeydowneffect(Effect onkeydowneffect) {
457         this.onkeydowneffect = onkeydowneffect;
458         JavascriptContext
459                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
460     }
461
462     /**
463      * <p>Return the value of the <code>onkeyupeffect</code> property.</p>
464      */

465     public Effect getOnkeyupeffect() {
466         if (onkeyupeffect != null) {
467             return onkeyupeffect;
468         }
469         ValueBinding vb = getValueBinding("onkeyupeffect");
470
471         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
472     }
473
474     /**
475      * <p>Set the value of the <code>onkeyupeffect</code> property.</p>
476      */

477     public void setOnkeyupeffect(Effect onkeyupeffect) {
478         this.onkeyupeffect = onkeyupeffect;
479         JavascriptContext
480                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
481     }
482
483     /**
484      * <p>Return the value of the <code>onkeyupeffect</code> property.</p>
485      */

486     public Effect getOnclickeffect() {
487         if (onclickeffect != null) {
488             return onclickeffect;
489         }
490         ValueBinding vb = getValueBinding("onclickeffect");
491
492         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
493     }
494
495
496     private String JavaDoc autocomplete;
497
498     /**
499      * <p>Set the value of the <code>autocomplete</code> property.</p>
500      */

501     public void setAutocomplete(String JavaDoc autocomplete) {
502         this.autocomplete = autocomplete;
503     }
504
505     /**
506      * <p>Return the value of the <code>autocomplete</code> property.</p>
507      */

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

520     public Object JavaDoc saveState(FacesContext context) {
521         Object JavaDoc values[] = new Object JavaDoc[21];
522         values[0] = super.saveState(context);
523         values[1] = partialSubmit;
524         values[2] = enabledOnUserRole;
525         values[3] = renderedOnUserRole;
526         values[4] = styleClass;
527         values[5] = effect;
528         values[13] = onchangeeffect;
529         values[19] = currentStyle;
530         values[20] = visible;
531         return ((Object JavaDoc) (values));
532     }
533
534     /**
535      * <p>Perform any processing required to restore the state from the entries
536      * in the state Object.</p>
537      */

538     public void restoreState(FacesContext context, Object JavaDoc state) {
539         Object JavaDoc values[] = (Object JavaDoc[]) state;
540         super.restoreState(context, values[0]);
541         partialSubmit = (Boolean JavaDoc) values[1];
542         enabledOnUserRole = (String JavaDoc) values[2];
543         renderedOnUserRole = (String JavaDoc) values[3];
544         styleClass = (String JavaDoc) values[4];
545         effect = (Effect) values[5];
546         onchangeeffect = (Effect) values[13];
547         currentStyle = (CurrentStyle) values[19];
548         visible = (Boolean JavaDoc) values[20];
549     }
550 }
551
552
553
Popular Tags