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        final FacesContext context, final UIComponent component, final String clientId, final 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(
67        final FacesContext facesContext, final MethodBinding methodBinding, final FacesEvent event) {
68      if (methodBinding != null && event != null) {
69        try {
70          methodBinding.invoke(facesContext, new Object[]{event});
71        } catch (final EvaluationException e) {
72          final Throwable cause = e.getCause();
73          if (cause instanceof AbortProcessingException) {
74            throw (AbortProcessingException) cause;
75          } else {
76            throw e;
77          }
78        }
79      }
80    }
81  
82    /**
83     * @deprecated since 2.0.0
84     */
85    @Deprecated
86    public static Object getValueFromValueBindingOrValueExpression(
87        final FacesContext context, final UIComponent component, final String name) {
88        return FacesUtilsEL.getValueFromValueBindingOrValueExpression(context, component, name);
89    }
90  
91    /**
92     * @deprecated since 2.0.0
93     */
94    @Deprecated
95    public static boolean hasValueBindingOrValueExpression(final UIComponent component, final String name) {
96        return FacesUtilsEL.hasValueBindingOrValueExpression(component, name);
97    }
98  
99    /**
100    * @deprecated since 2.0.0
101    */
102   @Deprecated
103   public static boolean isReadonlyValueBindingOrValueExpression(
104       final FacesContext context, final UIComponent component, final String name) {
105       return FacesUtilsEL.isReadonlyValueBindingOrValueExpression(context, component, name);
106   }
107 
108   /**
109    * @deprecated since 2.0.0
110    */
111   @Deprecated
112   public static String getExpressionString(final UIComponent component, final String name) {
113       return FacesUtilsEL.getExpressionString(component, name);
114   }
115 
116   /**
117    * @deprecated since 2.0.0
118    */
119   @Deprecated
120   public static void setValueOfBindingOrExpression(
121       final FacesContext context, final Object value, final UIComponent component, final String bindingName) {
122       FacesUtilsEL.setValueOfBindingOrExpression(context, value, component, bindingName);
123   }
124 
125   /**
126    * @deprecated since 2.0.0
127    */
128   @Deprecated
129   public static void setValueOfBindingOrExpression(
130       final FacesContext context, final Object value, final Object bindingOrExpression) {
131       FacesUtilsEL.setValueOfBindingOrExpression(context, value, bindingOrExpression);
132   }
133 
134   /**
135    * @deprecated since 2.0.0
136    */
137   @Deprecated
138   public static void copyValueBindingOrValueExpression(
139       final UIComponent fromComponent, final String fromName, final UIComponent toComponent, final String toName) {
140       FacesUtilsEL.copyValueBindingOrValueExpression(fromComponent, fromName, toComponent, toName);
141   }
142 
143   /**
144    * @deprecated since 2.0.0
145    */
146   @Deprecated
147   public static Object getValueFromBindingOrExpression(final Object obj) {
148       return FacesUtilsEL.getValueFromBindingOrExpression(obj);
149   }
150 
151   /**
152    * @deprecated since 2.0.0
153    */
154   @Deprecated
155   public static Object createExpressionOrBinding(final String string) {
156       return FacesUtilsEL.createExpressionOrBinding(string);
157   }
158 
159   /**
160    * @deprecated since 2.0.0
161    */
162   @Deprecated
163   public static void setValidator(final EditableValueHolder editableValueHolder, final Object validator) {
164       FacesUtilsEL.setValidator(editableValueHolder, validator);
165   }
166 
167   /**
168    * @deprecated since 2.0.0
169    */
170   @Deprecated
171   public static void setConverter(final ValueHolder valueHolder, final Object converterExpression) {
172       FacesUtilsEL.setConverter(valueHolder, converterExpression);
173   }
174 
175   /**
176    * @deprecated since 2.0.0
177    */
178   @Deprecated
179   public static void setBindingOrExpression(
180       final UIComponent component, final String name, final Object valueBindingOrExpression) {
181     FacesUtilsEL.setBindingOrExpression(component, name, valueBindingOrExpression);
182   }
183 
184   /**
185    * @deprecated since 2.0.0
186    */
187   @Deprecated
188   public static void setBindingOrExpression(
189       final UIComponent component, final String name, final String valueBindingOrExpression) {
190     setBindingOrExpression(component, name, createExpressionOrBinding(valueBindingOrExpression));
191   }
192 
193   /**
194    * @deprecated since 2.0.0
195    */
196   @Deprecated
197   public static void addBindingOrExpressionTabChangeListener(final TabChangeSource source, final String type,
198       final Object bindingOrExpression) {
199       FacesUtilsEL.addBindingOrExpressionTabChangeListener(source, type, bindingOrExpression);
200   }
201 
202   /**
203    * @deprecated since 2.0.0
204    */
205   @Deprecated
206   public static Comparator getBindingOrExpressionComparator(
207       final FacesContext facesContext, final UIComponent child, final String var, final boolean descending,
208       final Comparator comparator) {
209     return FacesUtilsEL.getBindingOrExpressionComparator(facesContext, child, var, descending, comparator);
210   }
211 
212   /**
213    * @deprecated since 2.0.0
214    */
215   @Deprecated
216   public static void addBindingOrExpressionPopupActionListener(
217       final ActionSource actionSource, final Object bindingOrExpression) {
218     FacesUtilsEL.addBindingOrExpressionPopupActionListener(actionSource, bindingOrExpression);
219   }
220 
221   /**
222    * @deprecated since 2.0.0
223    */
224   @Deprecated
225   public static void addBindingOrExpressionResetActionListener(
226       final ActionSource actionSource, final Object bindingOrExpression) {
227     FacesUtilsEL.addBindingOrExpressionResetActionListener(actionSource, bindingOrExpression);
228   }
229 
230   /**
231    * @deprecated since 2.0.0 Please call facesContext.getAttributes() directly.
232    */
233   @Deprecated
234   public static Map getFacesContextAttributes(final FacesContext facesContext) {
235     return facesContext.getAttributes();
236   }
237 
238   /**
239    * @deprecated since 2.0.0. Always true.
240    */
241   @Deprecated
242   public static boolean supportsEL() {
243     return true;
244   }
245 }