KickJava   Java API By Example, From Geeks To Geeks.

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


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.ext.taglib.Util;
38 import com.icesoft.faces.context.effects.CurrentStyle;
39 import com.icesoft.faces.context.effects.Effect;
40 import com.icesoft.faces.context.effects.JavascriptContext;
41
42 import javax.faces.context.FacesContext;
43 import javax.faces.el.ValueBinding;
44
45
46 /**
47  * This is an extension of javax.faces.component.html.HtmlOutputText, which
48  * provides some additional behavior to this component such as: <ul> <li>changes
49  * the component's rendered state based on the authentication</li> <li>adds
50  * effects to the component</li> <ul>
51  */

52 public class HtmlOutputText extends javax.faces.component.html.HtmlOutputText {
53     public static final String JavaDoc COMPONENT_TYPE =
54             "com.icesoft.faces.HtmlOutputText";
55     public static final String JavaDoc RENDERER_TYPE = "com.icesoft.faces.Text";
56     private static final boolean DEFAULT_VISIBLE = true;
57     private String JavaDoc styleClass = null;
58     private String JavaDoc renderedOnUserRole = null;
59     private Effect effect;
60     private Boolean JavaDoc visible = null;
61
62     private CurrentStyle currentStyle;
63
64     private Effect onclickeffect;
65     private Effect ondblclickeffect;
66     private Effect onmousedowneffect;
67     private Effect onmouseupeffect;
68     private Effect onmousemoveeffect;
69     private Effect onmouseovereffect;
70     private Effect onmouseouteffect;
71     private Effect onchangeeffect;
72     private Effect onkeypresseffect;
73     private Effect onkeydowneffect;
74     private Effect onkeyupeffect;
75
76     public HtmlOutputText() {
77         super();
78         setRendererType(RENDERER_TYPE);
79     }
80
81
82     public void setValueBinding(String JavaDoc s, ValueBinding vb) {
83
84         if (s != null && s.indexOf("effect") != -1) {
85
86             // If this is an effect attribute make sure Ice Extras is included
87
JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
88                                          getFacesContext());
89         }
90         super.setValueBinding(s, vb);
91     }
92
93     /**
94      * <p>Set the value of the <code>effect</code> property.</p>
95      */

96     public void setEffect(Effect effect) {
97         this.effect = effect;
98         JavascriptContext
99                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
100     }
101
102     /**
103      * <p>Return the value of the <code>effect</code> property.</p>
104      */

105     public Effect getEffect() {
106         if (effect != null) {
107             return effect;
108         }
109         ValueBinding vb = getValueBinding("effect");
110         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
111     }
112
113     /**
114      * <p>Set the value of the <code>visible</code> property.</p>
115      */

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

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

136     public void setRenderedOnUserRole(String JavaDoc renderedOnUserRole) {
137         this.renderedOnUserRole = renderedOnUserRole;
138     }
139
140     /**
141      * <p>Return the value of the <code>renderedOnUserRole</code> property.</p>
142      */

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

154     public void setStyleClass(String JavaDoc styleClass) {
155         this.styleClass = styleClass;
156     }
157
158     /**
159      * <p>Return the value of the <code>styleClass</code> property.</p>
160      */

161     public String JavaDoc getStyleClass() {
162         return Util.getQualifiedStyleClass(this,
163                 styleClass,
164                 CSS_DEFAULT.OUTPUT_TEXT_DEFAULT_STYLE_CLASS,
165                 "styleClass");
166     }
167
168     /**
169      * <p>Return the value of the <code>onclickeffect</code> property.</p>
170      */

171     public Effect getOnclickeffect() {
172         if (onclickeffect != null) {
173             return onclickeffect;
174         }
175         ValueBinding vb = getValueBinding("onclickeffect");
176
177         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
178     }
179
180     /**
181      * <p>Set the value of the <code>onclickeffect</code> property.</p>
182      */

183     public void setOnclickeffect(Effect onclickeffect) {
184         this.onclickeffect = onclickeffect;
185         JavascriptContext
186                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
187     }
188
189     /**
190      * <p>Return the value of the <code>ondblclickeffect</code> property.</p>
191      */

192     public Effect getOndblclickeffect() {
193         if (ondblclickeffect != null) {
194             return ondblclickeffect;
195         }
196         ValueBinding vb = getValueBinding("ondblclickeffect");
197
198         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
199     }
200
201     /**
202      * <p>Set the value of the <code>ondblclickeffect</code> property.</p>
203      */

204     public void setOndblclickeffect(Effect ondblclickeffect) {
205         this.ondblclickeffect = ondblclickeffect;
206         JavascriptContext
207                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
208     }
209
210     /**
211      * <p>Return the value of the <code>onmousedowneffect</code> property.</p>
212      */

213     public Effect getOnmousedowneffect() {
214         if (onmousedowneffect != null) {
215             return onmousedowneffect;
216         }
217         ValueBinding vb = getValueBinding("onmousedowneffect");
218
219         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
220     }
221
222     /**
223      * <p>Set the value of the <code>onmousedowneffect</code> property.</p>
224      */

225     public void setOnmousedowneffect(Effect onmousedowneffect) {
226         this.onmousedowneffect = onmousedowneffect;
227         JavascriptContext
228                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
229     }
230
231     /**
232      * <p>Return the value of the <code>onmouseupeffect</code> property.</p>
233      */

234     public Effect getOnmouseupeffect() {
235         if (onmouseupeffect != null) {
236             return onmouseupeffect;
237         }
238         ValueBinding vb = getValueBinding("onmouseupeffect");
239
240         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
241     }
242
243     /**
244      * <p>Set the value of the <code>onmouseupeffect</code> property.</p>
245      */

246     public void setOnmouseupeffect(Effect onmouseupeffect) {
247         this.onmouseupeffect = onmouseupeffect;
248         JavascriptContext
249                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
250     }
251
252     /**
253      * <p>Return the value of the <code>onmousemoveeffect</code> property.</p>
254      */

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

267     public void setOnmousemoveeffect(Effect onmousemoveeffect) {
268         this.onmousemoveeffect = onmousemoveeffect;
269         JavascriptContext
270                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
271     }
272
273     /**
274      * <p>Return the value of the <code>onmouseovereffect</code> property.</p>
275      */

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

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

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

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

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

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

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

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

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

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

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

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

402     public boolean isRendered() {
403         if (!Util.isRenderedOnUserRole(this)) {
404             return false;
405         }
406         return super.isRendered();
407     }
408
409     /**
410      * <p>Return the value of the <code>currentStyle</code> property.</p>
411      */

412     public CurrentStyle getCurrentStyle() {
413         return currentStyle;
414     }
415
416     /**
417      * <p>Set the value of the <code>currentStyle</code> property.</p>
418      */

419     public void setCurrentStyle(CurrentStyle currentStyle) {
420         this.currentStyle = currentStyle;
421     }
422
423     /**
424      * <p>Gets the state of the instance as a <code>Serializable</code>
425      * Object.</p>
426      */

427     public Object JavaDoc saveState(FacesContext context) {
428         Object JavaDoc values[] = new Object JavaDoc[19];
429         values[0] = super.saveState(context);
430         values[1] = renderedOnUserRole;
431         values[2] = styleClass;
432         values[3] = effect;
433         values[4] = onclickeffect;
434         values[5] = ondblclickeffect;
435         values[6] = onmousedowneffect;
436         values[7] = onmouseupeffect;
437         values[8] = onmousemoveeffect;
438         values[9] = onmouseovereffect;
439         values[10] = onmouseouteffect;
440         values[11] = onchangeeffect;
441         values[14] = onkeypresseffect;
442         values[15] = onkeydowneffect;
443         values[16] = onkeyupeffect;
444         values[17] = currentStyle;
445         values[18] = visible;
446         return ((Object JavaDoc) (values));
447     }
448
449     /**
450      * <p>Perform any processing required to restore the state from the entries
451      * in the state Object.</p>
452      */

453     public void restoreState(FacesContext context, Object JavaDoc state) {
454         Object JavaDoc values[] = (Object JavaDoc[]) state;
455         super.restoreState(context, values[0]);
456         renderedOnUserRole = (String JavaDoc) values[1];
457         styleClass = (String JavaDoc) values[2];
458         effect = (Effect) values[3];
459         onclickeffect = (Effect) values[4];
460         ondblclickeffect = (Effect) values[5];
461         onmousedowneffect = (Effect) values[6];
462         onmouseupeffect = (Effect) values[7];
463         onmousemoveeffect = (Effect) values[8];
464         onmouseovereffect = (Effect) values[9];
465         onmouseouteffect = (Effect) values[10];
466         onchangeeffect = (Effect) values[11];
467         onkeypresseffect = (Effect) values[14];
468         onkeydowneffect = (Effect) values[15];
469         onkeyupeffect = (Effect) values[16];
470         currentStyle = (CurrentStyle) values[17];
471         visible = (Boolean JavaDoc) values[18];
472     }
473 }
474
Popular Tags