View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.compat;
21  
22  import org.apache.myfaces.tobago.event.TabChangeSource;
23  
24  import javax.faces.component.ActionSource;
25  import javax.faces.component.ContextCallback;
26  import javax.faces.component.EditableValueHolder;
27  import javax.faces.component.UIComponent;
28  import javax.faces.component.ValueHolder;
29  import javax.faces.context.FacesContext;
30  import javax.faces.el.EvaluationException;
31  import javax.faces.el.MethodBinding;
32  import javax.faces.event.AbortProcessingException;
33  import javax.faces.event.FacesEvent;
34  import java.util.Comparator;
35  import java.util.Map;
36  
37  /**
38   * @deprecated since 2.0.0
39   */
40  @Deprecated
41  @SuppressWarnings("deprecation")
42  public class FacesUtils {
43  
44    private FacesUtils() {
45    }
46  
47    /**
48     * @deprecated since 2.0.0
49     */
50    @Deprecated
51    public static final Class[] VALIDATOR_ARGS = {FacesContext.class, UIComponent.class, Object.class};
52  
53    /**
54     * @deprecated since 2.0.0. Please use ComponentUtils.invokeOnComponent(context, this, clientId, callback)
55     */
56    @Deprecated
57    public static boolean invokeOnComponent(
58        FacesContext context, UIComponent component, String clientId, ContextCallback callback) {
59      return FacesInvokeOnComponent12.invokeOnComponent(context, component, clientId, callback);
60    }
61  
62    /**
63     * @deprecated since 2.0.0
64     */
65    @Deprecated
66    public static void invokeMethodBinding(FacesContext facesContext, MethodBinding methodBinding, FacesEvent event) {
67      if (methodBinding != null && event != null) {
68        try {
69          methodBinding.invoke(facesContext, new Object[]{event});
70        } catch (EvaluationException e) {
71          Throwable cause = e.getCause();
72          if (cause instanceof AbortProcessingException) {
73            throw (AbortProcessingException) cause;
74          } else {
75            throw e;
76          }
77        }
78      }
79    }
80  
81    /**
82     * @deprecated since 2.0.0
83     */
84    @Deprecated
85    public static Object getValueFromValueBindingOrValueExpression(
86        FacesContext context, UIComponent component, String name) {
87        return FacesUtilsEL.getValueFromValueBindingOrValueExpression(context, component, name);
88    }
89  
90    /**
91     * @deprecated since 2.0.0
92     */
93    @Deprecated
94    public static boolean hasValueBindingOrValueExpression(UIComponent component, String name) {
95        return FacesUtilsEL.hasValueBindingOrValueExpression(component, name);
96    }
97  
98    /**
99     * @deprecated since 2.0.0
100    */
101   @Deprecated
102   public static boolean isReadonlyValueBindingOrValueExpression(
103       FacesContext context, UIComponent component, String name) {
104       return FacesUtilsEL.isReadonlyValueBindingOrValueExpression(context, component, name);
105   }
106 
107   /**
108    * @deprecated since 2.0.0
109    */
110   @Deprecated
111   public static String getExpressionString(UIComponent component, String name) {
112       return FacesUtilsEL.getExpressionString(component, name);
113   }
114 
115   /**
116    * @deprecated since 2.0.0
117    */
118   @Deprecated
119   public static void setValueOfBindingOrExpression(
120       FacesContext context, Object value, UIComponent component, String bindingName) {
121       FacesUtilsEL.setValueOfBindingOrExpression(context, value, component, bindingName);
122   }
123 
124   /**
125    * @deprecated since 2.0.0
126    */
127   @Deprecated
128   public static void setValueOfBindingOrExpression(
129       FacesContext context, Object value, Object bindingOrExpression) {
130       FacesUtilsEL.setValueOfBindingOrExpression(context, value, bindingOrExpression);
131   }
132 
133   /**
134    * @deprecated since 2.0.0
135    */
136   @Deprecated
137   public static void copyValueBindingOrValueExpression(
138       UIComponent fromComponent, String fromName, UIComponent toComponent, String toName) {
139       FacesUtilsEL.copyValueBindingOrValueExpression(fromComponent, fromName, toComponent, toName);
140   }
141 
142   /**
143    * @deprecated since 2.0.0
144    */
145   @Deprecated
146   public static Object getValueFromBindingOrExpression(Object obj) {
147       return FacesUtilsEL.getValueFromBindingOrExpression(obj);
148   }
149 
150   /**
151    * @deprecated since 2.0.0
152    */
153   @Deprecated
154   public static Object createExpressionOrBinding(String string) {
155       return FacesUtilsEL.createExpressionOrBinding(string);
156   }
157 
158   /**
159    * @deprecated since 2.0.0
160    */
161   @Deprecated
162   public static void setValidator(EditableValueHolder editableValueHolder, Object validator) {
163       FacesUtilsEL.setValidator(editableValueHolder, validator);
164   }
165 
166   /**
167    * @deprecated since 2.0.0
168    */
169   @Deprecated
170   public static void setConverter(ValueHolder valueHolder, Object converterExpression) {
171       FacesUtilsEL.setConverter(valueHolder, converterExpression);
172   }
173 
174   /**
175    * @deprecated since 2.0.0
176    */
177   @Deprecated
178   public static void setBindingOrExpression(UIComponent component, String name, Object valueBindingOrExpression) {
179       FacesUtilsEL.setBindingOrExpression(component, name, valueBindingOrExpression);
180   }
181 
182   /**
183    * @deprecated since 2.0.0
184    */
185   @Deprecated
186   public static void setBindingOrExpression(UIComponent component, String name, String valueBindingOrExpression) {
187     setBindingOrExpression(component, name, createExpressionOrBinding(valueBindingOrExpression));
188   }
189 
190   /**
191    * @deprecated since 2.0.0
192    */
193   @Deprecated
194   public static void addBindingOrExpressionTabChangeListener(TabChangeSource source, String type,
195       Object bindingOrExpression) {
196       FacesUtilsEL.addBindingOrExpressionTabChangeListener(source, type, bindingOrExpression);
197   }
198 
199   /**
200    * @deprecated since 2.0.0
201    */
202   @Deprecated
203   public static Comparator getBindingOrExpressionComparator(
204       FacesContext facesContext, UIComponent child, String var, boolean descending, Comparator comparator) {
205       return FacesUtilsEL.getBindingOrExpressionComparator(facesContext, child, var, descending, comparator);
206   }
207 
208   /**
209    * @deprecated since 2.0.0
210    */
211   @Deprecated
212   public static void addBindingOrExpressionPopupActionListener(ActionSource actionSource, Object bindingOrExpression) {
213       FacesUtilsEL.addBindingOrExpressionPopupActionListener(actionSource, bindingOrExpression);
214   }
215 
216   /**
217    * @deprecated since 2.0.0
218    */
219   @Deprecated
220   public static void addBindingOrExpressionResetActionListener(ActionSource actionSource, Object bindingOrExpression) {
221       FacesUtilsEL.addBindingOrExpressionResetActionListener(actionSource, bindingOrExpression);
222   }
223 
224   /**
225    * @deprecated since 2.0.0 Please call facesContext.getAttributes() directly.
226    */
227   @Deprecated
228   public static Map getFacesContextAttributes(FacesContext facesContext) {
229     return facesContext.getAttributes();
230   }
231 
232   /**
233    * @deprecated since 2.0.0. Always true.
234    */
235   @Deprecated
236   public static boolean supportsEL() {
237     return true;
238   }
239 }