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: /* Original Copyright
034: * Copyright 2004 The Apache Software Foundation.
035: *
036: * Licensed under the Apache License, Version 2.0 (the "License");
037: * you may not use this file except in compliance with the License.
038: * You may obtain a copy of the License at
039: *
040: * http://www.apache.org/licenses/LICENSE-2.0
041: *
042: * Unless required by applicable law or agreed to in writing, software
043: * distributed under the License is distributed on an "AS IS" BASIS,
044: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
045: * See the License for the specific language governing permissions and
046: * limitations under the License.
047: */
048:
049: package com.icesoft.faces.component.ext;
050:
051: import com.icesoft.faces.component.CSS_DEFAULT;
052: import com.icesoft.faces.component.IceExtended;
053: import com.icesoft.faces.component.ext.taglib.Util;
054: import com.icesoft.faces.context.BridgeFacesContext;
055: import com.icesoft.faces.context.effects.CurrentStyle;
056: import com.icesoft.faces.context.effects.Effect;
057: import com.icesoft.faces.context.effects.JavascriptContext;
058:
059: import javax.faces.component.ActionSource;
060: import javax.faces.context.FacesContext;
061: import javax.faces.el.EvaluationException;
062: import javax.faces.el.MethodBinding;
063: import javax.faces.el.ValueBinding;
064: import javax.faces.event.AbortProcessingException;
065: import javax.faces.event.ActionEvent;
066: import javax.faces.event.ActionListener;
067: import javax.faces.event.FacesEvent;
068: import javax.faces.event.PhaseId;
069: import javax.faces.event.ValueChangeEvent;
070:
071: /**
072: * This is an extension of javax.faces.component.html.HtmlInputText, which
073: * provides some additional behavior to this component such as: <ul> <li>default
074: * classes for enabled and disabled state</li> <li>provides full and partial
075: * submit mechanism</li> <li>changes the component's enabled and rendered state
076: * based on the authentication</li> <li>adds effects to the component</li>
077: * <li>allows to set the action and actionListener for this component</li> <ul>
078: */
079:
080: public class HtmlInputText extends
081: javax.faces.component.html.HtmlInputText implements
082: IceExtended, ActionSource {
083:
084: public static final String COMPONENT_TYPE = "com.icesoft.faces.HtmlInputText";
085: public static final String RENDERER_TYPE = "com.icesoft.faces.Text";
086: private static final boolean DEFAULT_ACTION_KEY_EVENT = false;
087: private static final boolean DEFAULT_VISIBLE = true;
088: private String styleClass = null;
089: private Boolean partialSubmit = null;
090: private String enabledOnUserRole = null;
091: private String renderedOnUserRole = null;
092: private MethodBinding action = null;
093: private MethodBinding actionListener = null;
094: private Boolean actionKeyEvent;
095: private boolean immediate = false;
096: private boolean immediateSet = false;
097: private Effect effect;
098: private Boolean visible = null;
099: protected boolean focus = false;
100: private Effect onclickeffect;
101: private Effect ondblclickeffect;
102: private Effect onmousedowneffect;
103: private Effect onmouseupeffect;
104: private Effect onmousemoveeffect;
105: private Effect onmouseovereffect;
106: private Effect onmouseouteffect;
107: private Effect onchangeeffect;
108: private Effect onkeypresseffect;
109: private Effect onkeydowneffect;
110: private Effect onkeyupeffect;
111:
112: private CurrentStyle currentStyle;
113:
114: public HtmlInputText() {
115: super ();
116: setRendererType(RENDERER_TYPE);
117: }
118:
119: public String getText() {
120: return this .getConverter() == null ? (String) getValue() : this
121: .getConverter().getAsString(getFacesContext(), this ,
122: getValue());
123: }
124:
125: public void changeText(String value) {
126: Object newValue = this .getConverter() == null ? value : this
127: .getConverter().getAsObject(getFacesContext(), this ,
128: value);
129: this .setSubmittedValue(newValue);
130: this
131: .queueEvent(new ValueChangeEvent(this , getValue(),
132: newValue));
133: }
134:
135: public void setValueBinding(String s, ValueBinding vb) {
136: if (s != null && s.indexOf("effect") != -1) {
137: // If this is an effect attribute make sure Ice Extras is included
138: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
139: getFacesContext());
140: }
141: super .setValueBinding(s, vb);
142: }
143:
144: /**
145: * <p>Set the value of the <code>effect</code> property.</p>
146: */
147: public void setEffect(Effect effect) {
148: this .effect = effect;
149: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
150: getFacesContext());
151: }
152:
153: /**
154: * <p>Return the value of the <code>effect</code> property.</p>
155: */
156: public Effect getEffect() {
157: if (effect != null) {
158: return effect;
159: }
160: ValueBinding vb = getValueBinding("effect");
161: return vb != null ? (Effect) vb.getValue(getFacesContext())
162: : null;
163: }
164:
165: /**
166: * <p>Set the value of the <code>visible</code> property.</p>
167: */
168: public void setVisible(boolean visible) {
169: this .visible = Boolean.valueOf(visible);
170: }
171:
172: /**
173: * <p>Return the value of the <code>visible</code> property.</p>
174: */
175: public boolean getVisible() {
176: if (visible != null) {
177: return visible.booleanValue();
178: }
179: ValueBinding vb = getValueBinding("visible");
180: Boolean boolVal = vb != null ? (Boolean) vb
181: .getValue(getFacesContext()) : null;
182: return boolVal != null ? boolVal.booleanValue()
183: : DEFAULT_VISIBLE;
184: }
185:
186: /**
187: * <p>Set the value of the <code>partialSubmit</code> property.</p>
188: */
189: public void setPartialSubmit(boolean partialSubmit) {
190: this .partialSubmit = Boolean.valueOf(partialSubmit);
191: }
192:
193: /**
194: * <p>Return the value of the <code>partialSubmit</code> property.</p>
195: */
196: public boolean getPartialSubmit() {
197: if (partialSubmit != null) {
198: return partialSubmit.booleanValue();
199: }
200: ValueBinding vb = getValueBinding("partialSubmit");
201: Boolean boolVal = vb != null ? (Boolean) vb
202: .getValue(getFacesContext()) : null;
203: return boolVal != null ? boolVal.booleanValue() : Util
204: .isParentPartialSubmit(this );
205: }
206:
207: /**
208: * <p>Set the value of the <code>enabledOnUserRole</code> property.</p>
209: */
210: public void setEnabledOnUserRole(String enabledOnUserRole) {
211: this .enabledOnUserRole = enabledOnUserRole;
212: }
213:
214: /**
215: * <p>Return the value of the <code>enabledOnUserRole</code> property.</p>
216: */
217: public String getEnabledOnUserRole() {
218: if (enabledOnUserRole != null) {
219: return enabledOnUserRole;
220: }
221: ValueBinding vb = getValueBinding("enabledOnUserRole");
222: return vb != null ? (String) vb.getValue(getFacesContext())
223: : null;
224: }
225:
226: /**
227: * <p>Set the value of the <code>renderedOnUserRole</code> property.</p>
228: */
229: public void setRenderedOnUserRole(String renderedOnUserRole) {
230: this .renderedOnUserRole = renderedOnUserRole;
231: }
232:
233: /**
234: * <p>Return the value of the <code>renderedOnUserRole</code> property.</p>
235: */
236: public String getRenderedOnUserRole() {
237: if (renderedOnUserRole != null) {
238: return renderedOnUserRole;
239: }
240: ValueBinding vb = getValueBinding("renderedOnUserRole");
241: return vb != null ? (String) vb.getValue(getFacesContext())
242: : null;
243: }
244:
245: /**
246: * <p>Set the value of the <code>styleClass</code> property.</p>
247: */
248: public void setStyleClass(String styleClass) {
249: this .styleClass = styleClass;
250: }
251:
252: /**
253: * <p>Return the value of the <code>styleClass</code> property.</p>
254: */
255: public String getStyleClass() {
256: return Util.getQualifiedStyleClass(this , styleClass,
257: CSS_DEFAULT.INPUT_TEXT_DEFAULT_STYLE_CLASS,
258: "styleClass", isDisabled());
259:
260: }
261:
262: /**
263: * <p>Return the value of the <code>rendered</code> property.</p>
264: */
265: public boolean isRendered() {
266: if (!Util.isRenderedOnUserRole(this )) {
267: return false;
268: }
269: return super .isRendered();
270: }
271:
272: /**
273: * <p>Set the value of the <code>action</code> property.</p>
274: */
275: public void setAction(MethodBinding action) {
276: this .action = action;
277: }
278:
279: /**
280: * <p>Return the value of the <code>action</code> property.</p>
281: */
282: public MethodBinding getAction() {
283: return action;
284: }
285:
286: /* (non-Javadoc)
287: * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
288: */
289: public void setActionListener(MethodBinding actionListener) {
290: this .actionListener = actionListener;
291: }
292:
293: /* (non-Javadoc)
294: * @see javax.faces.component.ActionSource#getActionListener()
295: */
296: public MethodBinding getActionListener() {
297: return actionListener;
298: }
299:
300: /* (non-Javadoc)
301: * @see javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
302: */
303: public void addActionListener(ActionListener listener) {
304: addFacesListener(listener);
305: }
306:
307: /* (non-Javadoc)
308: * @see javax.faces.component.ActionSource#getActionListeners()
309: */
310: public ActionListener[] getActionListeners() {
311: return (ActionListener[]) getFacesListeners(ActionListener.class);
312: }
313:
314: /* (non-Javadoc)
315: * @see javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
316: */
317: public void removeActionListener(ActionListener listener) {
318: removeFacesListener(listener);
319: }
320:
321: /**
322: * <p>Set the value of the <code>actionKeyEvent</code> property.</p>
323: */
324: public void setActionKeyEvent(boolean actionKeyEvent) {
325: this .actionKeyEvent = Boolean.valueOf(actionKeyEvent);
326: }
327:
328: /**
329: * <p>Return the value of the <code>actionKeyEvent</code> property.</p>
330: */
331: public boolean isActionKeyEvent() {
332: if (actionKeyEvent != null) {
333: return actionKeyEvent.booleanValue();
334: }
335: ValueBinding vb = getValueBinding("actionKeyEvent");
336: Boolean boolVal = vb != null ? (Boolean) vb
337: .getValue(getFacesContext()) : null;
338: return boolVal != null ? boolVal.booleanValue()
339: : DEFAULT_ACTION_KEY_EVENT;
340: }
341:
342: /**
343: * <p>Return the value of the <code>onclickeffect</code> property.</p>
344: */
345: public Effect getOnclickeffect() {
346: if (onclickeffect != null) {
347: return onclickeffect;
348: }
349: ValueBinding vb = getValueBinding("onclickeffect");
350:
351: return vb != null ? (Effect) vb.getValue(getFacesContext())
352: : null;
353: }
354:
355: /**
356: * <p>Set the value of the <code>onclickeffect</code> property.</p>
357: */
358: public void setOnclickeffect(Effect onclickeffect) {
359: this .onclickeffect = onclickeffect;
360: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
361: getFacesContext());
362: }
363:
364: /**
365: * <p>Return the value of the <code>ondblclickeffect</code> property.</p>
366: */
367: public Effect getOndblclickeffect() {
368: if (ondblclickeffect != null) {
369: return ondblclickeffect;
370: }
371: ValueBinding vb = getValueBinding("ondblclickeffect");
372:
373: return vb != null ? (Effect) vb.getValue(getFacesContext())
374: : null;
375: }
376:
377: /**
378: * <p>Set the value of the <code>ondblclickeffect</code> property.</p>
379: */
380: public void setOndblclickeffect(Effect ondblclickeffect) {
381: this .ondblclickeffect = ondblclickeffect;
382: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
383: getFacesContext());
384: }
385:
386: /**
387: * <p>Return the value of the <code>onmousedowneffect</code> property.</p>
388: */
389: public Effect getOnmousedowneffect() {
390: if (onmousedowneffect != null) {
391: return onmousedowneffect;
392: }
393: ValueBinding vb = getValueBinding("onmousedowneffect");
394:
395: return vb != null ? (Effect) vb.getValue(getFacesContext())
396: : null;
397: }
398:
399: /**
400: * <p>Set the value of the <code>onmousedowneffect</code> property.</p>
401: */
402: public void setOnmousedowneffect(Effect onmousedowneffect) {
403: this .onmousedowneffect = onmousedowneffect;
404: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
405: getFacesContext());
406: }
407:
408: /**
409: * <p>Return the value of the <code>onmouseupeffect</code> property.</p>
410: */
411: public Effect getOnmouseupeffect() {
412: if (onmouseupeffect != null) {
413: return onmouseupeffect;
414: }
415: ValueBinding vb = getValueBinding("onmouseupeffect");
416:
417: return vb != null ? (Effect) vb.getValue(getFacesContext())
418: : null;
419: }
420:
421: /**
422: * <p>Set the value of the <code>onmouseupeffect</code> property.</p>
423: */
424: public void setOnmouseupeffect(Effect onmouseupeffect) {
425: this .onmouseupeffect = onmouseupeffect;
426: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
427: getFacesContext());
428: }
429:
430: /**
431: * <p>Return the value of the <code>onmousemoveeffect</code> property.</p>
432: */
433: public Effect getOnmousemoveeffect() {
434: if (onmousemoveeffect != null) {
435: return onmousemoveeffect;
436: }
437: ValueBinding vb = getValueBinding("onmousemoveeffect");
438:
439: return vb != null ? (Effect) vb.getValue(getFacesContext())
440: : null;
441: }
442:
443: /**
444: * <p>Set the value of the <code>onmousemoveeffect</code> property.</p>
445: */
446: public void setOnmousemoveeffect(Effect onmousemoveeffect) {
447: this .onmousemoveeffect = onmousemoveeffect;
448: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
449: getFacesContext());
450: }
451:
452: /**
453: * <p>Return the value of the <code>onmouseovereffect</code> property.</p>
454: */
455: public Effect getOnmouseovereffect() {
456: if (onmouseovereffect != null) {
457: return onmouseovereffect;
458: }
459: ValueBinding vb = getValueBinding("onmouseovereffect");
460:
461: return vb != null ? (Effect) vb.getValue(getFacesContext())
462: : null;
463: }
464:
465: /**
466: * <p>Set the value of the <code>onmouseovereffect</code> property.</p>
467: */
468: public void setOnmouseovereffect(Effect onmouseovereffect) {
469: this .onmouseovereffect = onmouseovereffect;
470: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
471: getFacesContext());
472: }
473:
474: /**
475: * <p>Return the value of the <code>onmouseouteffect</code> property.</p>
476: */
477: public Effect getOnmouseouteffect() {
478: if (onmouseouteffect != null) {
479: return onmouseouteffect;
480: }
481: ValueBinding vb = getValueBinding("onmouseouteffect");
482:
483: return vb != null ? (Effect) vb.getValue(getFacesContext())
484: : null;
485: }
486:
487: /**
488: * <p>Set the value of the <code>onmouseouteffect</code> property.</p>
489: */
490: public void setOnmouseouteffect(Effect onmouseouteffect) {
491: this .onmouseouteffect = onmouseouteffect;
492: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
493: getFacesContext());
494: }
495:
496: /**
497: * <p>Return the value of the <code>onchangeeffect</code> property.</p>
498: */
499: public Effect getOnchangeeffect() {
500: if (onchangeeffect != null) {
501: return onchangeeffect;
502: }
503: ValueBinding vb = getValueBinding("onchangeeffect");
504:
505: return vb != null ? (Effect) vb.getValue(getFacesContext())
506: : null;
507: }
508:
509: /**
510: * <p>Set the value of the <code>onchangeeffect</code> property.</p>
511: */
512: public void setOnchangeeffect(Effect onchangeeffect) {
513: this .onchangeeffect = onchangeeffect;
514: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
515: getFacesContext());
516: }
517:
518: /**
519: * <p>Return the value of the <code>onkeypresseffect</code> property.</p>
520: */
521: public Effect getOnkeypresseffect() {
522: if (onkeypresseffect != null) {
523: return onkeypresseffect;
524: }
525: ValueBinding vb = getValueBinding("onkeypresseffect");
526:
527: return vb != null ? (Effect) vb.getValue(getFacesContext())
528: : null;
529: }
530:
531: /**
532: * <p>Set the value of the <code>onkeypresseffect</code> property.</p>
533: */
534: public void setOnkeypresseffect(Effect onkeypresseffect) {
535: this .onkeypresseffect = onkeypresseffect;
536: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
537: getFacesContext());
538: }
539:
540: /**
541: * <p>Return the value of the <code>onkeydowneffect</code> property.</p>
542: */
543: public Effect getOnkeydowneffect() {
544: if (onkeydowneffect != null) {
545: return onkeydowneffect;
546: }
547: ValueBinding vb = getValueBinding("onkeydowneffect");
548:
549: return vb != null ? (Effect) vb.getValue(getFacesContext())
550: : null;
551: }
552:
553: /**
554: * <p>Set the value of the <code>onkeydowneffect</code> property.</p>
555: */
556: public void setOnkeydowneffect(Effect onkeydowneffect) {
557: this .onkeydowneffect = onkeydowneffect;
558: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
559: getFacesContext());
560: }
561:
562: /**
563: * <p>Return the value of the <code>onkeyupeffect</code> property.</p>
564: */
565: public Effect getOnkeyupeffect() {
566: if (onkeyupeffect != null) {
567: return onkeyupeffect;
568: }
569: ValueBinding vb = getValueBinding("onkeyupeffect");
570:
571: return vb != null ? (Effect) vb.getValue(getFacesContext())
572: : null;
573: }
574:
575: /**
576: * <p>Set the value of the <code>onkeyupeffect</code> property.</p>
577: */
578: public void setOnkeyupeffect(Effect onkeyupeffect) {
579: this .onkeyupeffect = onkeyupeffect;
580: JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
581: getFacesContext());
582: }
583:
584: /**
585: * <p>Return the value of the <code>currentStyle</code> property.</p>
586: */
587: public CurrentStyle getCurrentStyle() {
588: return currentStyle;
589: }
590:
591: /**
592: * <p>Set the value of the <code>currentStyle</code> property.</p>
593: */
594: public void setCurrentStyle(CurrentStyle currentStyle) {
595: this .currentStyle = currentStyle;
596: }
597:
598: /**
599: * <p>Gets the state of the instance as a <code>Serializable</code>
600: * Object.</p>
601: */
602: public Object saveState(FacesContext context) {
603: Object values[] = new Object[27];
604: values[0] = super .saveState(context);
605: values[1] = partialSubmit;
606: values[2] = enabledOnUserRole;
607: values[3] = renderedOnUserRole;
608: values[4] = styleClass;
609: values[5] = saveAttachedState(context, action);
610: values[6] = saveAttachedState(context, actionListener);
611: values[7] = actionKeyEvent;
612: values[8] = immediate ? Boolean.TRUE : Boolean.FALSE;
613: values[9] = immediateSet ? Boolean.TRUE : Boolean.FALSE;
614: values[10] = effect;
615: values[11] = onclickeffect;
616: values[12] = ondblclickeffect;
617: values[13] = onmousedowneffect;
618: values[14] = onmouseupeffect;
619: values[15] = onmousemoveeffect;
620: values[16] = onmouseovereffect;
621: values[17] = onmouseouteffect;
622: values[18] = onchangeeffect;
623: values[21] = onkeypresseffect;
624: values[22] = onkeydowneffect;
625: values[23] = onkeyupeffect;
626: values[24] = currentStyle;
627: values[25] = visible;
628: values[26] = autocomplete;
629: return ((Object) (values));
630: }
631:
632: /**
633: * <p>Perform any processing required to restore the state from the entries
634: * in the state Object.</p>
635: */
636: public void restoreState(FacesContext context, Object state) {
637: Object values[] = (Object[]) state;
638: super .restoreState(context, values[0]);
639: partialSubmit = (Boolean) values[1];
640: enabledOnUserRole = (String) values[2];
641: renderedOnUserRole = (String) values[3];
642: styleClass = (String) values[4];
643: action = (MethodBinding) restoreAttachedState(context,
644: values[5]);
645: actionListener = (MethodBinding) restoreAttachedState(context,
646: values[6]);
647: actionKeyEvent = (Boolean) values[7];
648: immediate = ((Boolean) values[8]).booleanValue();
649: immediateSet = ((Boolean) values[9]).booleanValue();
650: effect = (Effect) values[10];
651: onclickeffect = (Effect) values[11];
652: ondblclickeffect = (Effect) values[12];
653: onmousedowneffect = (Effect) values[13];
654: onmouseupeffect = (Effect) values[14];
655: onmousemoveeffect = (Effect) values[15];
656: onmouseovereffect = (Effect) values[16];
657: onmouseouteffect = (Effect) values[17];
658: onchangeeffect = (Effect) values[18];
659: onkeypresseffect = (Effect) values[21];
660: onkeydowneffect = (Effect) values[22];
661: onkeyupeffect = (Effect) values[23];
662: currentStyle = (CurrentStyle) values[24];
663: visible = (Boolean) values[25];
664: autocomplete = (String) values[26];
665: }
666:
667: /* (non-Javadoc)
668: * @see javax.faces.component.UIComponent#broadcast(javax.faces.event.FacesEvent)
669: */
670: public void broadcast(FacesEvent event)
671: throws AbortProcessingException {
672: try {
673: super .broadcast(event);
674: } catch (IllegalArgumentException e) {
675: //MyFaces thinks that a UIInput should bail out here, but
676: //it interferes with subclass event processing
677: }
678: if ((event instanceof ActionEvent)) {
679: ActionEvent actionEvent = (ActionEvent) event;
680: try {
681: MethodBinding actionListenerBinding = getActionListener();
682: if (actionListenerBinding != null) {
683: actionListenerBinding.invoke(getFacesContext(),
684: new Object[] { actionEvent });
685: }
686: // super.broadcast(event) does this itself
687: //ActionListener[] actionListeners = getActionListeners();
688: //if(actionListeners != null) {
689: // for(int i = 0; i < actionListeners.length; i++) {
690: // actionListeners[i].processAction(actionEvent);
691: // }
692: //}
693: } catch (EvaluationException e) {
694: Throwable cause = e.getCause();
695: if (cause != null
696: && cause instanceof AbortProcessingException) {
697: throw (AbortProcessingException) cause;
698: } else {
699: throw e;
700: }
701: }//try
702:
703: // Invoke the default ActionListener
704: ActionListener listener = getFacesContext()
705: .getApplication().getActionListener();
706: if (listener != null) {
707: listener.processAction((ActionEvent) event);
708: }
709: }
710: }
711:
712: /* (non-Javadoc)
713: * @see javax.faces.component.UIComponent#queueEvent(javax.faces.event.FacesEvent)
714: */
715: public void queueEvent(FacesEvent event) {
716: if (event instanceof ActionEvent) {
717: if (isImmediate()) {
718: event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
719: } else {
720: event.setPhaseId(PhaseId.INVOKE_APPLICATION);
721: }
722: }
723: super .queueEvent(event);
724: }
725:
726: /**
727: * <p>Return the value of the <code>immediate</code> property.</p>
728: */
729: public boolean isImmediate() {
730: if (this .immediateSet) {
731: return (this .immediate);
732: }
733: ValueBinding vb = getValueBinding("immediate");
734: if (vb != null) {
735: return (Boolean.TRUE.equals(vb.getValue(getFacesContext())));
736: } else {
737: return (this .immediate);
738: }
739: }
740:
741: /**
742: * <p>Return the value of the <code>disabled</code> property.</p>
743: */
744: public boolean isDisabled() {
745: if (!Util.isEnabledOnUserRole(this )) {
746: return true;
747: } else {
748: return super .isDisabled();
749: }
750: }
751:
752: /**
753: * <p>Set the value of the <code>immediate</code> property.</p>
754: */
755: public void setImmediate(boolean immediate) {
756: if (immediate != this .immediate) {
757: this .immediate = immediate;
758: }
759: this .immediateSet = true;
760:
761: }
762:
763: /* (non-Javadoc)
764: * @see javax.faces.component.UIComponent#decode(javax.faces.context.FacesContext)
765: */
766: public void decode(FacesContext context) {
767: super .decode(context);
768: }
769:
770: /**
771: * This method is used to communicate a focus request from the application
772: * to the client browser.
773: */
774: public void requestFocus() {
775: ((BridgeFacesContext) FacesContext.getCurrentInstance())
776: .setFocusId("null");
777: JavascriptContext.focus(FacesContext.getCurrentInstance(), this
778: .getClientId(FacesContext.getCurrentInstance()));
779: }
780:
781: /**
782: * <p>Set the value of the <code>focus</code> property.</p>
783: */
784: public void setFocus(boolean focus) {
785: this .focus = focus;
786: }
787:
788: /**
789: * <p>Return the value of the <code>focus</code> property.</p>
790: */
791: public boolean hasFocus() {
792: return focus;
793: }
794:
795: private String autocomplete;
796:
797: /**
798: * <p>Set the value of the <code>autocomplete</code> property.</p>
799: */
800: public void setAutocomplete(String autocomplete) {
801: this .autocomplete = autocomplete;
802: }
803:
804: /**
805: * <p>Return the value of the <code>autocomplete</code> property.</p>
806: */
807: public String getAutocomplete() {
808: if (autocomplete != null) {
809: return autocomplete;
810: }
811: ValueBinding vb = getValueBinding("autocomplete");
812: return vb != null ? (String) vb.getValue(getFacesContext())
813: : null;
814: }
815: }
|