KickJava   Java API By Example, From Geeks To Geeks.

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


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 /* Original Copyright
34  * Copyright 2004 The Apache Software Foundation.
35  *
36  * Licensed under the Apache License, Version 2.0 (the "License");
37  * you may not use this file except in compliance with the License.
38  * You may obtain a copy of the License at
39  *
40  * http://www.apache.org/licenses/LICENSE-2.0
41  *
42  * Unless required by applicable law or agreed to in writing, software
43  * distributed under the License is distributed on an "AS IS" BASIS,
44  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45  * See the License for the specific language governing permissions and
46  * limitations under the License.
47  */

48
49 package com.icesoft.faces.component.ext;
50
51 import com.icesoft.faces.component.CSS_DEFAULT;
52 import com.icesoft.faces.component.IceExtended;
53 import com.icesoft.faces.component.ext.taglib.Util;
54 import com.icesoft.faces.context.BridgeFacesContext;
55 import com.icesoft.faces.context.effects.CurrentStyle;
56 import com.icesoft.faces.context.effects.Effect;
57 import com.icesoft.faces.context.effects.JavascriptContext;
58
59 import javax.faces.component.ActionSource;
60 import javax.faces.context.FacesContext;
61 import javax.faces.el.EvaluationException;
62 import javax.faces.el.MethodBinding;
63 import javax.faces.el.ValueBinding;
64 import javax.faces.event.AbortProcessingException;
65 import javax.faces.event.ActionEvent;
66 import javax.faces.event.ActionListener;
67 import javax.faces.event.FacesEvent;
68 import javax.faces.event.PhaseId;
69 import javax.faces.event.ValueChangeEvent;
70
71 /**
72  * This is an extension of javax.faces.component.html.HtmlInputText, which
73  * provides some additional behavior to this component such as: <ul> <li>default
74  * classes for enabled and disabled state</li> <li>provides full and partial
75  * submit mechanism</li> <li>changes the component's enabled and rendered state
76  * based on the authentication</li> <li>adds effects to the component</li>
77  * <li>allows to set the action and actionListener for this component</li> <ul>
78  */

79
80 public class HtmlInputText
81         extends javax.faces.component.html.HtmlInputText
82         implements IceExtended, ActionSource {
83
84     public static final String JavaDoc COMPONENT_TYPE =
85             "com.icesoft.faces.HtmlInputText";
86     public static final String JavaDoc RENDERER_TYPE = "com.icesoft.faces.Text";
87     private static final boolean DEFAULT_ACTION_KEY_EVENT = false;
88     private static final boolean DEFAULT_VISIBLE = true;
89     private String JavaDoc styleClass = null;
90     private Boolean JavaDoc partialSubmit = null;
91     private String JavaDoc enabledOnUserRole = null;
92     private String JavaDoc renderedOnUserRole = null;
93     private MethodBinding action = null;
94     private MethodBinding actionListener = null;
95     private Boolean JavaDoc actionKeyEvent;
96     private boolean immediate = false;
97     private boolean immediateSet = false;
98     private Effect effect;
99     private Boolean JavaDoc visible = null;
100     protected boolean focus = false;
101     private Effect onclickeffect;
102     private Effect ondblclickeffect;
103     private Effect onmousedowneffect;
104     private Effect onmouseupeffect;
105     private Effect onmousemoveeffect;
106     private Effect onmouseovereffect;
107     private Effect onmouseouteffect;
108     private Effect onchangeeffect;
109     private Effect onkeypresseffect;
110     private Effect onkeydowneffect;
111     private Effect onkeyupeffect;
112
113     private CurrentStyle currentStyle;
114
115     public HtmlInputText() {
116         super();
117         setRendererType(RENDERER_TYPE);
118     }
119
120     public String JavaDoc getText() {
121         return this.getConverter() == null ? (String JavaDoc) getValue() : this
122                 .getConverter()
123                 .getAsString(getFacesContext(), this, getValue());
124     }
125
126     public void changeText(String JavaDoc value) {
127         Object JavaDoc newValue = this.getConverter() == null ? value : this
128                 .getConverter().getAsObject(getFacesContext(), this, value);
129         this.setSubmittedValue(newValue);
130         this.queueEvent(new ValueChangeEvent(this, getValue(), newValue));
131     }
132
133
134     public void setValueBinding(String JavaDoc s, ValueBinding vb) {
135         if (s != null && s.indexOf("effect") != -1) {
136             // If this is an effect attribute make sure Ice Extras is included
137
JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS,
138                                          getFacesContext());
139         }
140         super.setValueBinding(s, vb);
141     }
142
143     /**
144      * <p>Set the value of the <code>effect</code> property.</p>
145      */

146     public void setEffect(Effect effect) {
147         this.effect = effect;
148         JavascriptContext
149                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
150     }
151
152     /**
153      * <p>Return the value of the <code>effect</code> property.</p>
154      */

155     public Effect getEffect() {
156         if (effect != null) {
157             return effect;
158         }
159         ValueBinding vb = getValueBinding("effect");
160         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
161     }
162
163     /**
164      * <p>Set the value of the <code>visible</code> property.</p>
165      */

166     public void setVisible(boolean visible) {
167         this.visible = Boolean.valueOf(visible);
168     }
169
170     /**
171      * <p>Return the value of the <code>visible</code> property.</p>
172      */

173     public boolean getVisible() {
174         if (visible != null) {
175             return visible.booleanValue();
176         }
177         ValueBinding vb = getValueBinding("visible");
178         Boolean JavaDoc boolVal =
179                 vb != null ? (Boolean JavaDoc) vb.getValue(getFacesContext()) : null;
180         return boolVal != null ? boolVal.booleanValue() : DEFAULT_VISIBLE;
181     }
182
183     /**
184      * <p>Set the value of the <code>partialSubmit</code> property.</p>
185      */

186     public void setPartialSubmit(boolean partialSubmit) {
187         this.partialSubmit = Boolean.valueOf(partialSubmit);
188     }
189
190     /**
191      * <p>Return the value of the <code>partialSubmit</code> property.</p>
192      */

193     public boolean getPartialSubmit() {
194         if (partialSubmit != null) {
195             return partialSubmit.booleanValue();
196         }
197         ValueBinding vb = getValueBinding("partialSubmit");
198         Boolean JavaDoc boolVal =
199                 vb != null ? (Boolean JavaDoc) vb.getValue(getFacesContext()) : null;
200         return boolVal != null ? boolVal.booleanValue() :
201                Util.isParentPartialSubmit(this);
202     }
203
204     /**
205      * <p>Set the value of the <code>enabledOnUserRole</code> property.</p>
206      */

207     public void setEnabledOnUserRole(String JavaDoc enabledOnUserRole) {
208         this.enabledOnUserRole = enabledOnUserRole;
209     }
210
211     /**
212      * <p>Return the value of the <code>enabledOnUserRole</code> property.</p>
213      */

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

225     public void setRenderedOnUserRole(String JavaDoc renderedOnUserRole) {
226         this.renderedOnUserRole = renderedOnUserRole;
227     }
228
229     /**
230      * <p>Return the value of the <code>renderedOnUserRole</code> property.</p>
231      */

232     public String JavaDoc getRenderedOnUserRole() {
233         if (renderedOnUserRole != null) {
234             return renderedOnUserRole;
235         }
236         ValueBinding vb = getValueBinding("renderedOnUserRole");
237         return vb != null ? (String JavaDoc) vb.getValue(getFacesContext()) : null;
238     }
239
240     /**
241      * <p>Set the value of the <code>styleClass</code> property.</p>
242      */

243     public void setStyleClass(String JavaDoc styleClass) {
244         this.styleClass = styleClass;
245     }
246
247     /**
248      * <p>Return the value of the <code>styleClass</code> property.</p>
249      */

250     public String JavaDoc getStyleClass() {
251         return Util.getQualifiedStyleClass(this,
252                 styleClass,
253                 CSS_DEFAULT.INPUT_TEXT_DEFAULT_STYLE_CLASS,
254                 "styleClass",
255                 isDisabled());
256                                              
257     }
258
259     /**
260      * <p>Return the value of the <code>rendered</code> property.</p>
261      */

262     public boolean isRendered() {
263         if (!Util.isRenderedOnUserRole(this)) {
264             return false;
265         }
266         return super.isRendered();
267     }
268
269     /**
270      * <p>Set the value of the <code>action</code> property.</p>
271      */

272     public void setAction(MethodBinding action) {
273         this.action = action;
274     }
275
276     /**
277      * <p>Return the value of the <code>action</code> property.</p>
278      */

279     public MethodBinding getAction() {
280         return action;
281     }
282
283     /* (non-Javadoc)
284      * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
285      */

286     public void setActionListener(MethodBinding actionListener) {
287         this.actionListener = actionListener;
288     }
289
290     /* (non-Javadoc)
291      * @see javax.faces.component.ActionSource#getActionListener()
292      */

293     public MethodBinding getActionListener() {
294         return actionListener;
295     }
296
297     /* (non-Javadoc)
298      * @see javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
299      */

300     public void addActionListener(ActionListener listener) {
301         addFacesListener(listener);
302     }
303
304     /* (non-Javadoc)
305      * @see javax.faces.component.ActionSource#getActionListeners()
306      */

307     public ActionListener[] getActionListeners() {
308         return (ActionListener[]) getFacesListeners(ActionListener.class);
309     }
310
311     /* (non-Javadoc)
312      * @see javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
313      */

314     public void removeActionListener(ActionListener listener) {
315         removeFacesListener(listener);
316     }
317
318     /**
319      * <p>Set the value of the <code>actionKeyEvent</code> property.</p>
320      */

321     public void setActionKeyEvent(boolean actionKeyEvent) {
322         this.actionKeyEvent = Boolean.valueOf(actionKeyEvent);
323     }
324
325     /**
326      * <p>Return the value of the <code>actionKeyEvent</code> property.</p>
327      */

328     public boolean isActionKeyEvent() {
329         if (actionKeyEvent != null) {
330             return actionKeyEvent.booleanValue();
331         }
332         ValueBinding vb = getValueBinding("actionKeyEvent");
333         Boolean JavaDoc boolVal =
334                 vb != null ? (Boolean JavaDoc) vb.getValue(getFacesContext()) : null;
335         return boolVal != null ? boolVal.booleanValue() :
336                DEFAULT_ACTION_KEY_EVENT;
337     }
338
339     /**
340      * <p>Return the value of the <code>onclickeffect</code> property.</p>
341      */

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

354     public void setOnclickeffect(Effect onclickeffect) {
355         this.onclickeffect = onclickeffect;
356         JavascriptContext
357                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
358     }
359
360     /**
361      * <p>Return the value of the <code>ondblclickeffect</code> property.</p>
362      */

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

375     public void setOndblclickeffect(Effect ondblclickeffect) {
376         this.ondblclickeffect = ondblclickeffect;
377         JavascriptContext
378                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
379     }
380
381     /**
382      * <p>Return the value of the <code>onmousedowneffect</code> property.</p>
383      */

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

396     public void setOnmousedowneffect(Effect onmousedowneffect) {
397         this.onmousedowneffect = onmousedowneffect;
398         JavascriptContext
399                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
400     }
401
402     /**
403      * <p>Return the value of the <code>onmouseupeffect</code> property.</p>
404      */

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

417     public void setOnmouseupeffect(Effect onmouseupeffect) {
418         this.onmouseupeffect = onmouseupeffect;
419         JavascriptContext
420                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
421     }
422
423     /**
424      * <p>Return the value of the <code>onmousemoveeffect</code> property.</p>
425      */

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

438     public void setOnmousemoveeffect(Effect onmousemoveeffect) {
439         this.onmousemoveeffect = onmousemoveeffect;
440         JavascriptContext
441                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
442     }
443
444     /**
445      * <p>Return the value of the <code>onmouseovereffect</code> property.</p>
446      */

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

459     public void setOnmouseovereffect(Effect onmouseovereffect) {
460         this.onmouseovereffect = onmouseovereffect;
461         JavascriptContext
462                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
463     }
464
465     /**
466      * <p>Return the value of the <code>onmouseouteffect</code> property.</p>
467      */

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

480     public void setOnmouseouteffect(Effect onmouseouteffect) {
481         this.onmouseouteffect = onmouseouteffect;
482         JavascriptContext
483                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
484     }
485
486     /**
487      * <p>Return the value of the <code>onchangeeffect</code> property.</p>
488      */

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

501     public void setOnchangeeffect(Effect onchangeeffect) {
502         this.onchangeeffect = onchangeeffect;
503         JavascriptContext
504                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
505     }
506
507     /**
508      * <p>Return the value of the <code>onkeypresseffect</code> property.</p>
509      */

510     public Effect getOnkeypresseffect() {
511         if (onkeypresseffect != null) {
512             return onkeypresseffect;
513         }
514         ValueBinding vb = getValueBinding("onkeypresseffect");
515
516         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
517     }
518
519     /**
520      * <p>Set the value of the <code>onkeypresseffect</code> property.</p>
521      */

522     public void setOnkeypresseffect(Effect onkeypresseffect) {
523         this.onkeypresseffect = onkeypresseffect;
524         JavascriptContext
525                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
526     }
527
528     /**
529      * <p>Return the value of the <code>onkeydowneffect</code> property.</p>
530      */

531     public Effect getOnkeydowneffect() {
532         if (onkeydowneffect != null) {
533             return onkeydowneffect;
534         }
535         ValueBinding vb = getValueBinding("onkeydowneffect");
536
537         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
538     }
539
540     /**
541      * <p>Set the value of the <code>onkeydowneffect</code> property.</p>
542      */

543     public void setOnkeydowneffect(Effect onkeydowneffect) {
544         this.onkeydowneffect = onkeydowneffect;
545         JavascriptContext
546                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
547     }
548
549     /**
550      * <p>Return the value of the <code>onkeyupeffect</code> property.</p>
551      */

552     public Effect getOnkeyupeffect() {
553         if (onkeyupeffect != null) {
554             return onkeyupeffect;
555         }
556         ValueBinding vb = getValueBinding("onkeyupeffect");
557
558         return vb != null ? (Effect) vb.getValue(getFacesContext()) : null;
559     }
560
561     /**
562      * <p>Set the value of the <code>onkeyupeffect</code> property.</p>
563      */

564     public void setOnkeyupeffect(Effect onkeyupeffect) {
565         this.onkeyupeffect = onkeyupeffect;
566         JavascriptContext
567                 .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
568     }
569
570     /**
571      * <p>Return the value of the <code>currentStyle</code> property.</p>
572      */

573     public CurrentStyle getCurrentStyle() {
574         return currentStyle;
575     }
576
577     /**
578      * <p>Set the value of the <code>currentStyle</code> property.</p>
579      */

580     public void setCurrentStyle(CurrentStyle currentStyle) {
581         this.currentStyle = currentStyle;
582     }
583
584
585     /**
586      * <p>Gets the state of the instance as a <code>Serializable</code>
587      * Object.</p>
588      */

589     public Object JavaDoc saveState(FacesContext context) {
590         Object JavaDoc values[] = new Object JavaDoc[27];
591         values[0] = super.saveState(context);
592         values[1] = partialSubmit;
593         values[2] = enabledOnUserRole;
594         values[3] = renderedOnUserRole;
595         values[4] = styleClass;
596         values[5] = saveAttachedState(context, action);
597         values[6] = saveAttachedState(context, actionListener);
598         values[7] = actionKeyEvent;
599         values[8] = immediate ? Boolean.TRUE : Boolean.FALSE;
600         values[9] = immediateSet ? Boolean.TRUE : Boolean.FALSE;
601         values[10] = effect;
602         values[11] = onclickeffect;
603         values[12] = ondblclickeffect;
604         values[13] = onmousedowneffect;
605         values[14] = onmouseupeffect;
606         values[15] = onmousemoveeffect;
607         values[16] = onmouseovereffect;
608         values[17] = onmouseouteffect;
609         values[18] = onchangeeffect;
610         values[21] = onkeypresseffect;
611         values[22] = onkeydowneffect;
612         values[23] = onkeyupeffect;
613         values[24] = currentStyle;
614         values[25] = visible;
615         values[26] = autocomplete;
616         return ((Object JavaDoc) (values));
617     }
618
619     /**
620      * <p>Perform any processing required to restore the state from the entries
621      * in the state Object.</p>
622      */

623     public void restoreState(FacesContext context, Object JavaDoc state) {
624         Object JavaDoc values[] = (Object JavaDoc[]) state;
625         super.restoreState(context, values[0]);
626         partialSubmit = (Boolean JavaDoc) values[1];
627         enabledOnUserRole = (String JavaDoc) values[2];
628         renderedOnUserRole = (String JavaDoc) values[3];
629         styleClass = (String JavaDoc) values[4];
630         action = (MethodBinding) restoreAttachedState(context, values[5]);
631         actionListener =
632                 (MethodBinding) restoreAttachedState(context, values[6]);
633         actionKeyEvent = (Boolean JavaDoc) values[7];
634         immediate = ((Boolean JavaDoc) values[8]).booleanValue();
635         immediateSet = ((Boolean JavaDoc) values[9]).booleanValue();
636         effect = (Effect) values[10];
637         onclickeffect = (Effect) values[11];
638         ondblclickeffect = (Effect) values[12];
639         onmousedowneffect = (Effect) values[13];
640         onmouseupeffect = (Effect) values[14];
641         onmousemoveeffect = (Effect) values[15];
642         onmouseovereffect = (Effect) values[16];
643         onmouseouteffect = (Effect) values[17];
644         onchangeeffect = (Effect) values[18];
645         onkeypresseffect = (Effect) values[21];
646         onkeydowneffect = (Effect) values[22];
647         onkeyupeffect = (Effect) values[23];
648         currentStyle = (CurrentStyle) values[24];
649         visible = (Boolean JavaDoc) values[25];
650         autocomplete = (String JavaDoc) values[26];
651     }
652
653
654     /* (non-Javadoc)
655      * @see javax.faces.component.UIComponent#broadcast(javax.faces.event.FacesEvent)
656      */

657     public void broadcast(FacesEvent event) throws AbortProcessingException {
658         try {
659             super.broadcast(event);
660         } catch (IllegalArgumentException JavaDoc e) {
661             //MyFaces thinks that a UIInput should bail out here, but
662
//it interferes with subclass event processing
663
}
664         if ((event instanceof ActionEvent)) {
665             ActionEvent actionEvent = (ActionEvent) event;
666             try {
667                 MethodBinding actionListenerBinding = getActionListener();
668                 if (actionListenerBinding != null) {
669                     actionListenerBinding.invoke(
670                         getFacesContext(), new Object JavaDoc[]{actionEvent});
671                 }
672                 // super.broadcast(event) does this itself
673
//ActionListener[] actionListeners = getActionListeners();
674
//if(actionListeners != null) {
675
// for(int i = 0; i < actionListeners.length; i++) {
676
// actionListeners[i].processAction(actionEvent);
677
// }
678
//}
679
} catch (EvaluationException e) {
680                 Throwable JavaDoc cause = e.getCause();
681                 if (cause != null &&
682                     cause instanceof AbortProcessingException) {
683                     throw(AbortProcessingException) cause;
684                 } else {
685                     throw e;
686                 }
687             }//try
688

689             // Invoke the default ActionListener
690
ActionListener listener =
691                     getFacesContext().getApplication().getActionListener();
692             if (listener != null) {
693                 listener.processAction((ActionEvent) event);
694             }
695         }
696     }
697
698
699     /* (non-Javadoc)
700      * @see javax.faces.component.UIComponent#queueEvent(javax.faces.event.FacesEvent)
701      */

702     public void queueEvent(FacesEvent event) {
703         if (event instanceof ActionEvent) {
704             if (isImmediate()) {
705                 event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
706             } else {
707                 event.setPhaseId(PhaseId.INVOKE_APPLICATION);
708             }
709         }
710         super.queueEvent(event);
711     }
712
713
714     /**
715      * <p>Return the value of the <code>immediate</code> property.</p>
716      */

717     public boolean isImmediate() {
718         if (this.immediateSet) {
719             return (this.immediate);
720         }
721         ValueBinding vb = getValueBinding("immediate");
722         if (vb != null) {
723             return (Boolean.TRUE.equals(vb.getValue(getFacesContext())));
724         } else {
725             return (this.immediate);
726         }
727     }
728
729     /**
730      * <p>Return the value of the <code>disabled</code> property.</p>
731      */

732     public boolean isDisabled() {
733         if (!Util.isEnabledOnUserRole(this)) {
734             return true;
735         } else {
736             return super.isDisabled();
737         }
738     }
739
740     /**
741      * <p>Set the value of the <code>immediate</code> property.</p>
742      */

743     public void setImmediate(boolean immediate) {
744         if (immediate != this.immediate) {
745             this.immediate = immediate;
746         }
747         this.immediateSet = true;
748
749     }
750
751     /* (non-Javadoc)
752      * @see javax.faces.component.UIComponent#decode(javax.faces.context.FacesContext)
753      */

754     public void decode(FacesContext context) {
755         super.decode(context);
756     }
757
758     /**
759      * This method is used to communicate a focus request from the application
760      * to the client browser.
761      */

762     public void requestFocus() {
763         ((BridgeFacesContext) FacesContext.getCurrentInstance())
764                 .setFocusId("null");
765         JavascriptContext.focus(FacesContext.getCurrentInstance(),
766                                 this.getClientId(
767                                         FacesContext.getCurrentInstance()));
768     }
769
770     /**
771      * <p>Set the value of the <code>focus</code> property.</p>
772      */

773     public void setFocus(boolean focus) {
774         this.focus = focus;
775     }
776
777     /**
778      * <p>Return the value of the <code>focus</code> property.</p>
779      */

780     public boolean hasFocus() {
781         return focus;
782     }
783
784     private String JavaDoc autocomplete;
785
786     /**
787      * <p>Set the value of the <code>autocomplete</code> property.</p>
788      */

789     public void setAutocomplete(String JavaDoc autocomplete) {
790         this.autocomplete = autocomplete;
791     }
792
793     /**
794      * <p>Return the value of the <code>autocomplete</code> property.</p>
795      */

796     public String JavaDoc getAutocomplete() {
797         if (autocomplete != null) {
798             return autocomplete;
799         }
800         ValueBinding vb = getValueBinding("autocomplete");
801         return vb != null ? (String JavaDoc) vb.getValue(getFacesContext()) : null;
802     }
803 }
804
Popular Tags