View Javadoc

1   // WARNING: This file was automatically generated. Do not edit it directly,
2   //          or you will lose your changes.
3   
4   /*
5    * Licensed to the Apache Software Foundation (ASF) under one
6    * or more contributor license agreements.  See the NOTICE file
7    * distributed with this work for additional information
8    * regarding copyright ownership.  The ASF licenses this file
9    * to you under the Apache License, Version 2.0 (the
10   * "License"); you may not use this file except in compliance
11   * with the License.  You may obtain a copy of the License at
12   *
13   *   http://www.apache.org/licenses/LICENSE-2.0
14   *
15   * Unless required by applicable law or agreed to in writing,
16   * software distributed under the License is distributed on an
17   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18   * KIND, either express or implied.  See the License for the
19   * specific language governing permissions and limitations
20   * under the License.
21  */
22  package org.apache.myfaces.trinidad.component;
23  
24  import javax.faces.component.ActionSource;
25  import javax.faces.context.FacesContext;
26  import javax.faces.el.MethodBinding;
27  import javax.faces.event.AbortProcessingException;
28  import javax.faces.event.ActionEvent;
29  import javax.faces.event.ActionListener;
30  import javax.faces.event.FacesEvent;
31  import javax.faces.event.PhaseId;
32  import org.apache.myfaces.trinidad.bean.FacesBean;
33  import org.apache.myfaces.trinidad.bean.PropertyKey;
34  import org.apache.myfaces.trinidad.util.ComponentUtils;
35  
36  /**
37   *
38   * UIXProgress is a base abstraction for 
39   *           components that implement ActionSource and 
40   *           indicate the progress of tasks running in
41   * 	    the server, typically navigating to a special
42   *           page once the task is complete.
43   * 	    When the task is complete, an ActionEvent is
44   * 	    delivered.
45   *
46   * <h4>Events:</h4>
47   * <table border="1" width="100%" cellpadding="3" summary="">
48   * <tr bgcolor="#CCCCFF" class="TableHeadingColor">
49   * <th align="left">Type</th>
50   * <th align="left">Phases</th>
51   * <th align="left">Description</th>
52   * </tr>
53   * <tr class="TableRowColor">
54   * <td valign="top"><code>javax.faces.event.ActionEvent</code></td>
55   * <td valign="top" nowrap>Any<br>Phase<br>Invoke<br>Application</td>
56   * <td valign="top">Event delivered when the "action" of the component has been
57  invoked;  for example, by clicking on a button.  The action may result
58  in page navigation.</td>
59   * </tr>
60   * <tr class="TableRowColor">
61   * <td valign="top"><code>org.apache.myfaces.trinidad.event.AttributeChangeEvent</code></td>
62   * <td valign="top" nowrap>Invoke<br>Application<br>Apply<br>Request<br>Values</td>
63   * <td valign="top">Event delivered to describe an attribute change.  Attribute change events are not delivered for any programmatic change to a property.  They are only delivered when a renderer changes a property without the application's specific request.  An example of an attribute change event might include the width of a column that supported client-side resizing.</td>
64   * </tr>
65   * </table>
66   */
67  public class UIXProgress extends UIXComponentBase
68                           implements ActionSource
69  {
70    static public final FacesBean.Type TYPE = new FacesBean.Type(
71      UIXComponentBase.TYPE);
72    static public final PropertyKey VALUE_KEY =
73      TYPE.registerKey("value", Object.class, null, 0, PropertyKey.Mutable.SOMETIMES);
74    static public final PropertyKey ACTION_KEY =
75      TYPE.registerKey("action", MethodBinding.class, PropertyKey.CAP_NOT_BOUND | PropertyKey.CAP_STATE_HOLDER);
76    static public final PropertyKey ACTION_LISTENER_KEY =
77      TYPE.registerKey("actionListener", MethodBinding.class, PropertyKey.CAP_NOT_BOUND | PropertyKey.CAP_STATE_HOLDER);
78    static public final PropertyKey IMMEDIATE_KEY =
79      TYPE.registerKey("immediate", Boolean.class, Boolean.FALSE);
80  
81    static public final String COMPONENT_FAMILY =
82      "org.apache.myfaces.trinidad.Progress";
83    static public final String COMPONENT_TYPE =
84      "org.apache.myfaces.trinidad.Progress";
85  
86    /**
87     * Construct an instance of the UIXProgress.
88     */
89    public UIXProgress()
90    {
91      super("org.apache.myfaces.trinidad.Indicator");
92    }
93      
94    @Override
95    public void queueEvent(FacesEvent e)
96    {
97      if (e.getSource() == this && e instanceof ActionEvent)
98      {
99        if (isImmediate())
100         e.setPhaseId(PhaseId.ANY_PHASE);
101       else
102         e.setPhaseId(PhaseId.INVOKE_APPLICATION);
103     }
104 
105     super.queueEvent(e);
106   }
107 
108   @Override
109   public void broadcast(FacesEvent event) throws AbortProcessingException
110   {
111     super.broadcast(event);
112 
113     // Notify the specified action listener method (if any),
114     // and the default action listener
115     if (event instanceof ActionEvent)
116     {
117       FacesContext context = getFacesContext();
118       MethodBinding mb = getActionListener();
119       if (mb != null)
120         mb.invoke(context, new Object[] { event });
121 
122       ActionListener defaultActionListener =
123         context.getApplication().getActionListener();
124       if (defaultActionListener != null)
125       {
126         defaultActionListener.processAction((ActionEvent) event);
127       }
128     }
129   }
130 
131   /**
132    * Gets The data model being used by this progress component.
133    *               The model should be of type 
134    *               org.apache.myfaces.trinidad.model.BoundedRangeModel.
135    *
136    * @return  the new value value
137    */
138   final public Object getValue()
139   {
140     return getProperty(VALUE_KEY);
141   }
142 
143   /**
144    * Sets The data model being used by this progress component.
145    *               The model should be of type 
146    *               org.apache.myfaces.trinidad.model.BoundedRangeModel.
147    * 
148    * @param value  the new value value
149    */
150   final public void setValue(Object value)
151   {
152     setProperty(VALUE_KEY, (value));
153   }
154 
155   /**
156    * Gets A reference to an action method sent by the progress component, 
157    *               or the static outcome of an action. This is invoked when the task
158    *               under progress is complete.
159    *
160    * @return  the new action value
161    */
162   final public MethodBinding getAction()
163   {
164     return (MethodBinding)getProperty(ACTION_KEY);
165   }
166 
167   /**
168    * Sets A reference to an action method sent by the progress component, 
169    *               or the static outcome of an action. This is invoked when the task
170    *               under progress is complete.
171    * 
172    * @param action  the new action value
173    */
174   final public void setAction(MethodBinding action)
175   {
176     setProperty(ACTION_KEY, (action));
177   }
178 
179   /**
180    * Gets A method reference to an action listener.
181    *             This is invoked after the task in progress is complete.
182    *
183    * @return  the new actionListener value
184    */
185   final public MethodBinding getActionListener()
186   {
187     return (MethodBinding)getProperty(ACTION_LISTENER_KEY);
188   }
189 
190   /**
191    * Sets A method reference to an action listener.
192    *             This is invoked after the task in progress is complete.
193    * 
194    * @param actionListener  the new actionListener value
195    */
196   final public void setActionListener(MethodBinding actionListener)
197   {
198     setProperty(ACTION_LISTENER_KEY, (actionListener));
199   }
200 
201   /**
202    * Gets whether data validation - client-side or
203    *             server-side -
204    *           will be skipped when
205    *           events are generated by this component.
206    * 
207    *           When immediate is true, the command's action and
208    *           ActionListeners, including the default ActionListener
209    *           provided by the JavaServer Faces implementation,
210    *           will be executed during Apply Request Values phase
211    *           of the request processing lifecycle, rather than
212    *           waiting until the Invoke Application phase.  Because
213    *           validation runs during Process Validators (after
214    *           Apply Request Values, but before Invoke Application),
215    *           setting immediate to true will skip validation.
216    *
217    * @return  the new immediate value
218    */
219   final public boolean isImmediate()
220   {
221     return ComponentUtils.resolveBoolean(getProperty(IMMEDIATE_KEY), false);
222   }
223 
224   /**
225    * Sets whether data validation - client-side or
226    *             server-side -
227    *           will be skipped when
228    *           events are generated by this component.
229    * 
230    *           When immediate is true, the command's action and
231    *           ActionListeners, including the default ActionListener
232    *           provided by the JavaServer Faces implementation,
233    *           will be executed during Apply Request Values phase
234    *           of the request processing lifecycle, rather than
235    *           waiting until the Invoke Application phase.  Because
236    *           validation runs during Process Validators (after
237    *           Apply Request Values, but before Invoke Application),
238    *           setting immediate to true will skip validation.
239    * 
240    * @param immediate  the new immediate value
241    */
242   final public void setImmediate(boolean immediate)
243   {
244     setProperty(IMMEDIATE_KEY, immediate ? Boolean.TRUE : Boolean.FALSE);
245   }
246 
247   /**
248    * Adds a action listener.
249    *
250    * @param listener  the action listener to add
251    */
252   final public void addActionListener(
253     ActionListener listener)
254   {
255     addFacesListener(listener);
256   }
257 
258   /**
259    * Removes a action listener.
260    *
261    * @param listener  the action listener to remove
262    */
263   final public void removeActionListener(
264     ActionListener listener)
265   {
266     removeFacesListener(listener);
267   }
268 
269   /**
270    * Returns an array of attached action listeners.
271    *
272    * @return  an array of attached action listeners.
273    */
274   final public ActionListener[] getActionListeners()
275   {
276     return (ActionListener[])getFacesListeners(ActionListener.class);
277   }
278 
279   @Override
280   public String getFamily()
281   {
282     return COMPONENT_FAMILY;
283   }
284 
285   @Override
286   protected FacesBean.Type getBeanType()
287   {
288     return TYPE;
289   }
290 
291   /**
292    * Construct an instance of the UIXProgress.
293    */
294   protected UIXProgress(
295     String rendererType
296     )
297   {
298     super(rendererType);
299   }
300 
301   static
302   {
303     TYPE.lockAndRegister("org.apache.myfaces.trinidad.Progress","org.apache.myfaces.trinidad.Indicator");
304   }
305 }