KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

219     public boolean isDisabled() {
220         if (!Util.isEnabledOnUserRole(this)) {
221             return true;
222         } else {
223             return super.isDisabled();
224         }
225     }
226
227     /**
228      * <p>Return the value of the <code>styleClass</code> property.</p>
229      */

230     public String JavaDoc getStyleClass() {
231         return Util.getQualifiedStyleClass(this,
232                 styleClass,
233                 CSS_DEFAULT.SELECT_MANY_MENU_DEFAULT_STYLE_CLASS,
234                 "styleClass",
235                 isDisabled());
236     }
237
238     /**
239      * <p>Set the value of the <code>rendered</code> property.</p>
240      */

241     public boolean isRendered() {
242         if (!Util.isRenderedOnUserRole(this)) {
243             return false;
244         }
245         return super.isRendered();
246     }
247
248
249     /**
250      * <p>Return the value of the <code>onchangeeffect</code> property.</p>
251      */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

509     public String JavaDoc getAutocomplete() {
510         if (autocomplete != null) {
511             return autocomplete;
512         }
513         ValueBinding vb = getValueBinding("autocomplete");
514         return vb != null ? (String JavaDoc) vb.getValue(getFacesContext()) : null;
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