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.el.MethodExpression;
25  import javax.faces.el.MethodBinding;
26  import javax.faces.event.AbortProcessingException;
27  import javax.faces.event.FacesEvent;
28  import javax.faces.event.PhaseId;
29  import org.apache.myfaces.trinidad.bean.FacesBean;
30  import org.apache.myfaces.trinidad.bean.PropertyKey;
31  import org.apache.myfaces.trinidad.event.PollEvent;
32  import org.apache.myfaces.trinidad.event.PollListener;
33  import org.apache.myfaces.trinidad.util.ComponentUtils;
34  
35  /**
36   *
37   * The poll component initiates poll to the server.
38   *
39   * <h4>Events:</h4>
40   * <table border="1" width="100%" cellpadding="3" summary="">
41   * <tr bgcolor="#CCCCFF" class="TableHeadingColor">
42   * <th align="left">Type</th>
43   * <th align="left">Phases</th>
44   * <th align="left">Description</th>
45   * </tr>
46   * <tr class="TableRowColor">
47   * <td valign="top"><code>org.apache.myfaces.trinidad.event.PollEvent</code></td>
48   * <td valign="top" nowrap>Apply<br>Request<br>Values<br>Invoke<br>Application</td>
49   * <td valign="top">Event delivered when the poll component polls the server.</td>
50   * </tr>
51   * <tr class="TableRowColor">
52   * <td valign="top"><code>org.apache.myfaces.trinidad.event.AttributeChangeEvent</code></td>
53   * <td valign="top" nowrap>Invoke<br>Application<br>Apply<br>Request<br>Values</td>
54   * <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>
55   * </tr>
56   * </table>
57   */
58  public class UIXPoll extends UIXComponentBase
59  {
60    static public final FacesBean.Type TYPE = new FacesBean.Type(
61      UIXComponentBase.TYPE);
62    static public final PropertyKey IMMEDIATE_KEY =
63      TYPE.registerKey("immediate", Boolean.class, Boolean.FALSE);
64    static public final PropertyKey POLL_LISTENER_KEY =
65      TYPE.registerKey("pollListener", MethodExpression.class);
66  
67    static public final String COMPONENT_FAMILY =
68      "org.apache.myfaces.trinidad.Poll";
69    static public final String COMPONENT_TYPE =
70      "org.apache.myfaces.trinidad.Poll";
71  
72    /**
73     * Construct an instance of the UIXPoll.
74     */
75    public UIXPoll()
76    {
77      super("org.apache.myfaces.trinidad.Poll");
78    }
79      
80  
81    @Deprecated
82    public void setPollListener(MethodBinding binding)
83    {
84      setPollListener(adaptMethodBinding(binding));
85    }
86  
87    //
88    // Abstract methods implemented by subclass.
89    @Override
90    public void broadcast(FacesEvent event) throws AbortProcessingException
91    {
92      // Perform standard superclass processing
93      super.broadcast(event);
94  
95      // Notify the specified Poll listener method (if any)
96      if (event instanceof PollEvent)
97      {
98        broadcastToMethodExpression(event, getPollListener());
99      }
100   }
101 
102   @Override
103   public void queueEvent(FacesEvent e)
104   {
105     if ((e instanceof PollEvent) && (e.getSource() == this))
106     {
107       if (isImmediate())
108       {
109         e.setPhaseId(PhaseId.ANY_PHASE);
110       }
111       else
112       {
113         e.setPhaseId(PhaseId.INVOKE_APPLICATION);
114       }
115     }
116 
117     super.queueEvent(e);
118   }
119 
120   /**
121    * Gets whether data validation 
122    *           should be skipped when poll
123    *           events are generated by this component.
124    * 
125    *           When immediate is false (the default), events will
126    *           be delivered during the Invoke Application phase, which
127    *           will trigger validation.  When set to true,  events
128    *           will be executed during the Apply Request Values phase.
129    *
130    * @return  the new immediate value
131    */
132   final public boolean isImmediate()
133   {
134     return ComponentUtils.resolveBoolean(getProperty(IMMEDIATE_KEY), false);
135   }
136 
137   /**
138    * Sets whether data validation 
139    *           should be skipped when poll
140    *           events are generated by this component.
141    * 
142    *           When immediate is false (the default), events will
143    *           be delivered during the Invoke Application phase, which
144    *           will trigger validation.  When set to true,  events
145    *           will be executed during the Apply Request Values phase.
146    * 
147    * @param immediate  the new immediate value
148    */
149   final public void setImmediate(boolean immediate)
150   {
151     setProperty(IMMEDIATE_KEY, immediate ? Boolean.TRUE : Boolean.FALSE);
152   }
153 
154   /**
155    * Gets a method reference to a poll listener
156    *
157    * @return  the new pollListener value
158    */
159   final public MethodExpression getPollListener()
160   {
161     return (MethodExpression)getProperty(POLL_LISTENER_KEY);
162   }
163 
164   /**
165    * Sets a method reference to a poll listener
166    * 
167    * @param pollListener  the new pollListener value
168    */
169   final public void setPollListener(MethodExpression pollListener)
170   {
171     setProperty(POLL_LISTENER_KEY, (pollListener));
172   }
173 
174   /**
175    * Adds a poll listener.
176    *
177    * @param listener  the poll listener to add
178    */
179   final public void addPollListener(
180     PollListener listener)
181   {
182     addFacesListener(listener);
183   }
184 
185   /**
186    * Removes a poll listener.
187    *
188    * @param listener  the poll listener to remove
189    */
190   final public void removePollListener(
191     PollListener listener)
192   {
193     removeFacesListener(listener);
194   }
195 
196   /**
197    * Returns an array of attached poll listeners.
198    *
199    * @return  an array of attached poll listeners.
200    */
201   final public PollListener[] getPollListeners()
202   {
203     return (PollListener[])getFacesListeners(PollListener.class);
204   }
205 
206   @Override
207   public String getFamily()
208   {
209     return COMPONENT_FAMILY;
210   }
211 
212   @Override
213   protected FacesBean.Type getBeanType()
214   {
215     return TYPE;
216   }
217 
218   /**
219    * Construct an instance of the UIXPoll.
220    */
221   protected UIXPoll(
222     String rendererType
223     )
224   {
225     super(rendererType);
226   }
227 
228   static
229   {
230     TYPE.lockAndRegister("org.apache.myfaces.trinidad.Poll","org.apache.myfaces.trinidad.Poll");
231   }
232 }