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.ext.taglib.Util;
038: import com.icesoft.faces.context.effects.CurrentStyle;
039: import com.icesoft.faces.context.effects.Effect;
040: import com.icesoft.faces.context.effects.JavascriptContext;
041:
042: import javax.faces.context.FacesContext;
043: import javax.faces.el.ValueBinding;
044:
045: /**
046: * This is an extension of javax.faces.component.html.HtmlOutputText, which
047: * provides some additional behavior to this component such as: <ul> <li>changes
048: * the component's rendered state based on the authentication</li> <li>adds
049: * effects to the component</li> <ul>
050: */
051: public class HtmlOutputText extends
052: javax.faces.component.html.HtmlOutputText {
053: public static final String COMPONENT_TYPE = "com.icesoft.faces.HtmlOutputText";
054: public static final String RENDERER_TYPE = "com.icesoft.faces.Text";
055: private static final boolean DEFAULT_VISIBLE = true;
056: private String styleClass = null;
057: private String renderedOnUserRole = null;
058: private Effect effect;
059: private Boolean visible = null;
060:
061: private CurrentStyle currentStyle;
062:
063: private Effect onclickeffect;
064: private Effect ondblclickeffect;
065: private Effect onmousedowneffect;
066: private Effect onmouseupeffect;
067: private Effect onmousemoveeffect;
068: private Effect onmouseovereffect;
069: private Effect onmouseouteffect;
070: private Effect onchangeeffect;
071: private Effect onkeypresseffect;
072: private Effect onkeydowneffect;
073: private Effect onkeyupeffect;
074:
075: public HtmlOutputText() {
076: super ();
077: setRendererType(RENDERER_TYPE);
078: }
079:
080: public void setValueBinding(String s, ValueBinding vb) {
081:
082: if (s != null && s.indexOf("effect") != -1) {
083:
084: // If this is an effect attribute make sure Ice Extras is included
085: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
086: getFacesContext());
087: }
088: super .setValueBinding(s, vb);
089: }
090:
091: /**
092: * <p>Set the value of the <code>effect</code> property.</p>
093: */
094: public void setEffect(Effect effect) {
095: this .effect = effect;
096: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
097: getFacesContext());
098: }
099:
100: /**
101: * <p>Return the value of the <code>effect</code> property.</p>
102: */
103: public Effect getEffect() {
104: if (effect != null) {
105: return effect;
106: }
107: ValueBinding vb = getValueBinding("effect");
108: return vb != null ? (Effect) vb.getValue(getFacesContext())
109: : null;
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 boolVal = vb != null ? (Boolean) vb
128: .getValue(getFacesContext()) : null;
129: return boolVal != null ? boolVal.booleanValue()
130: : DEFAULT_VISIBLE;
131: }
132:
133: /**
134: * <p>Set the value of the <code>renderedOnUserRole</code> property.</p>
135: */
136: public void setRenderedOnUserRole(String renderedOnUserRole) {
137: this .renderedOnUserRole = renderedOnUserRole;
138: }
139:
140: /**
141: * <p>Return the value of the <code>renderedOnUserRole</code> property.</p>
142: */
143: public String getRenderedOnUserRole() {
144: if (renderedOnUserRole != null) {
145: return renderedOnUserRole;
146: }
147: ValueBinding vb = getValueBinding("renderedOnUserRole");
148: return vb != null ? (String) vb.getValue(getFacesContext())
149: : null;
150: }
151:
152: /**
153: * <p>Set the value of the <code>styleClass</code> property.</p>
154: */
155: public void setStyleClass(String styleClass) {
156: this .styleClass = styleClass;
157: }
158:
159: /**
160: * <p>Return the value of the <code>styleClass</code> property.</p>
161: */
162: public String getStyleClass() {
163: return Util.getQualifiedStyleClass(this , 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())
178: : null;
179: }
180:
181: /**
182: * <p>Set the value of the <code>onclickeffect</code> property.</p>
183: */
184: public void setOnclickeffect(Effect onclickeffect) {
185: this .onclickeffect = onclickeffect;
186: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
187: getFacesContext());
188: }
189:
190: /**
191: * <p>Return the value of the <code>ondblclickeffect</code> property.</p>
192: */
193: public Effect getOndblclickeffect() {
194: if (ondblclickeffect != null) {
195: return ondblclickeffect;
196: }
197: ValueBinding vb = getValueBinding("ondblclickeffect");
198:
199: return vb != null ? (Effect) vb.getValue(getFacesContext())
200: : null;
201: }
202:
203: /**
204: * <p>Set the value of the <code>ondblclickeffect</code> property.</p>
205: */
206: public void setOndblclickeffect(Effect ondblclickeffect) {
207: this .ondblclickeffect = ondblclickeffect;
208: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
209: getFacesContext());
210: }
211:
212: /**
213: * <p>Return the value of the <code>onmousedowneffect</code> property.</p>
214: */
215: public Effect getOnmousedowneffect() {
216: if (onmousedowneffect != null) {
217: return onmousedowneffect;
218: }
219: ValueBinding vb = getValueBinding("onmousedowneffect");
220:
221: return vb != null ? (Effect) vb.getValue(getFacesContext())
222: : null;
223: }
224:
225: /**
226: * <p>Set the value of the <code>onmousedowneffect</code> property.</p>
227: */
228: public void setOnmousedowneffect(Effect onmousedowneffect) {
229: this .onmousedowneffect = onmousedowneffect;
230: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
231: getFacesContext());
232: }
233:
234: /**
235: * <p>Return the value of the <code>onmouseupeffect</code> property.</p>
236: */
237: public Effect getOnmouseupeffect() {
238: if (onmouseupeffect != null) {
239: return onmouseupeffect;
240: }
241: ValueBinding vb = getValueBinding("onmouseupeffect");
242:
243: return vb != null ? (Effect) vb.getValue(getFacesContext())
244: : null;
245: }
246:
247: /**
248: * <p>Set the value of the <code>onmouseupeffect</code> property.</p>
249: */
250: public void setOnmouseupeffect(Effect onmouseupeffect) {
251: this .onmouseupeffect = onmouseupeffect;
252: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
253: getFacesContext());
254: }
255:
256: /**
257: * <p>Return the value of the <code>onmousemoveeffect</code> property.</p>
258: */
259: public Effect getOnmousemoveeffect() {
260: if (onmousemoveeffect != null) {
261: return onmousemoveeffect;
262: }
263: ValueBinding vb = getValueBinding("onmousemoveeffect");
264:
265: return vb != null ? (Effect) vb.getValue(getFacesContext())
266: : null;
267: }
268:
269: /**
270: * <p>Set the value of the <code>onmousemoveeffect</code> property.</p>
271: */
272: public void setOnmousemoveeffect(Effect onmousemoveeffect) {
273: this .onmousemoveeffect = onmousemoveeffect;
274: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
275: getFacesContext());
276: }
277:
278: /**
279: * <p>Return the value of the <code>onmouseovereffect</code> property.</p>
280: */
281: public Effect getOnmouseovereffect() {
282: if (onmouseovereffect != null) {
283: return onmouseovereffect;
284: }
285: ValueBinding vb = getValueBinding("onmouseovereffect");
286:
287: return vb != null ? (Effect) vb.getValue(getFacesContext())
288: : null;
289: }
290:
291: /**
292: * <p>Set the value of the <code>onmouseovereffect</code> property.</p>
293: */
294: public void setOnmouseovereffect(Effect onmouseovereffect) {
295: this .onmouseovereffect = onmouseovereffect;
296: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
297: getFacesContext());
298: }
299:
300: /**
301: * <p>Return the value of the <code>onmouseouteffect</code> property.</p>
302: */
303: public Effect getOnmouseouteffect() {
304: if (onmouseouteffect != null) {
305: return onmouseouteffect;
306: }
307: ValueBinding vb = getValueBinding("onmouseouteffect");
308:
309: return vb != null ? (Effect) vb.getValue(getFacesContext())
310: : null;
311: }
312:
313: /**
314: * <p>Set the value of the <code>onmouseouteffect</code> property.</p>
315: */
316: public void setOnmouseouteffect(Effect onmouseouteffect) {
317: this .onmouseouteffect = onmouseouteffect;
318: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
319: getFacesContext());
320: }
321:
322: /**
323: * <p>Return the value of the <code>onchangeeffect</code> property.</p>
324: */
325: public Effect getOnchangeeffect() {
326: if (onchangeeffect != null) {
327: return onchangeeffect;
328: }
329: ValueBinding vb = getValueBinding("onchangeeffect");
330:
331: return vb != null ? (Effect) vb.getValue(getFacesContext())
332: : null;
333: }
334:
335: /**
336: * <p>Set the value of the <code>onchangeeffect</code> property.</p>
337: */
338: public void setOnchangeeffect(Effect onchangeeffect) {
339: this .onchangeeffect = onchangeeffect;
340: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
341: getFacesContext());
342: }
343:
344: /**
345: * <p>Return the value of the <code>onkeypresseffect</code> property.</p>
346: */
347: public Effect getOnkeypresseffect() {
348: if (onkeypresseffect != null) {
349: return onkeypresseffect;
350: }
351: ValueBinding vb = getValueBinding("onkeypresseffect");
352:
353: return vb != null ? (Effect) vb.getValue(getFacesContext())
354: : null;
355: }
356:
357: /**
358: * <p>Set the value of the <code>onkeypresseffect</code> property.</p>
359: */
360: public void setOnkeypresseffect(Effect onkeypresseffect) {
361: this .onkeypresseffect = onkeypresseffect;
362: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
363: getFacesContext());
364: }
365:
366: /**
367: * <p>Return the value of the <code>onkeydowneffect</code> property.</p>
368: */
369: public Effect getOnkeydowneffect() {
370: if (onkeydowneffect != null) {
371: return onkeydowneffect;
372: }
373: ValueBinding vb = getValueBinding("onkeydowneffect");
374:
375: return vb != null ? (Effect) vb.getValue(getFacesContext())
376: : null;
377: }
378:
379: /**
380: * <p>Set the value of the <code>onkeydowneffect</code> property.</p>
381: */
382: public void setOnkeydowneffect(Effect onkeydowneffect) {
383: this .onkeydowneffect = onkeydowneffect;
384: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
385: getFacesContext());
386: }
387:
388: /**
389: * <p>Return the value of the <code>onkeyupeffect</code> property.</p>
390: */
391: public Effect getOnkeyupeffect() {
392: if (onkeyupeffect != null) {
393: return onkeyupeffect;
394: }
395: ValueBinding vb = getValueBinding("onkeyupeffect");
396:
397: return vb != null ? (Effect) vb.getValue(getFacesContext())
398: : null;
399: }
400:
401: /**
402: * <p>Set the value of the <code>onkeyupeffect</code> property.</p>
403: */
404: public void setOnkeyupeffect(Effect onkeyupeffect) {
405: this .onkeyupeffect = onkeyupeffect;
406: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
407: getFacesContext());
408: }
409:
410: /**
411: * <p>Return the value of the <code>rendered</code> property.</p>
412: */
413: public boolean isRendered() {
414: if (!Util.isRenderedOnUserRole(this )) {
415: return false;
416: }
417: return super .isRendered();
418: }
419:
420: /**
421: * <p>Return the value of the <code>currentStyle</code> property.</p>
422: */
423: public CurrentStyle getCurrentStyle() {
424: return currentStyle;
425: }
426:
427: /**
428: * <p>Set the value of the <code>currentStyle</code> property.</p>
429: */
430: public void setCurrentStyle(CurrentStyle currentStyle) {
431: this .currentStyle = currentStyle;
432: }
433:
434: /**
435: * <p>Gets the state of the instance as a <code>Serializable</code>
436: * Object.</p>
437: */
438: public Object saveState(FacesContext context) {
439: Object values[] = new Object[19];
440: values[0] = super .saveState(context);
441: values[1] = renderedOnUserRole;
442: values[2] = styleClass;
443: values[3] = effect;
444: values[4] = onclickeffect;
445: values[5] = ondblclickeffect;
446: values[6] = onmousedowneffect;
447: values[7] = onmouseupeffect;
448: values[8] = onmousemoveeffect;
449: values[9] = onmouseovereffect;
450: values[10] = onmouseouteffect;
451: values[11] = onchangeeffect;
452: values[14] = onkeypresseffect;
453: values[15] = onkeydowneffect;
454: values[16] = onkeyupeffect;
455: values[17] = currentStyle;
456: values[18] = visible;
457: return ((Object) (values));
458: }
459:
460: /**
461: * <p>Perform any processing required to restore the state from the entries
462: * in the state Object.</p>
463: */
464: public void restoreState(FacesContext context, Object state) {
465: Object values[] = (Object[]) state;
466: super .restoreState(context, values[0]);
467: renderedOnUserRole = (String) values[1];
468: styleClass = (String) values[2];
469: effect = (Effect) values[3];
470: onclickeffect = (Effect) values[4];
471: ondblclickeffect = (Effect) values[5];
472: onmousedowneffect = (Effect) values[6];
473: onmouseupeffect = (Effect) values[7];
474: onmousemoveeffect = (Effect) values[8];
475: onmouseovereffect = (Effect) values[9];
476: onmouseouteffect = (Effect) values[10];
477: onchangeeffect = (Effect) values[11];
478: onkeypresseffect = (Effect) values[14];
479: onkeydowneffect = (Effect) values[15];
480: onkeyupeffect = (Effect) values[16];
481: currentStyle = (CurrentStyle) values[17];
482: visible = (Boolean) values[18];
483: }
484: }
|