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.renderkit;
21  
22  import org.apache.myfaces.tobago.internal.util.Deprecation;
23  import org.apache.myfaces.tobago.layout.Measure;
24  import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
25  
26  import javax.faces.component.UIComponent;
27  import javax.faces.context.FacesContext;
28  import javax.faces.convert.ConverterException;
29  import javax.faces.model.SelectItem;
30  import java.io.IOException;
31  import java.util.List;
32  
33  /**
34   * @deprecated please use {@link org.apache.myfaces.tobago.renderkit.util.RenderUtils}
35   */
36  @Deprecated
37  public class RenderUtil {
38  
39    public static final String COMPONENT_IN_REQUEST = "org.apache.myfaces.tobago.component";
40  
41    private RenderUtil() {
42      // to prevent instantiation
43    }
44  
45    public static boolean contains(Object[] list, Object value) {
46      Deprecation.LOG.warn("Using deprecated API");
47      if (list == null) {
48        return false;
49      }
50      for (Object aList : list) {
51        if (aList != null && aList.equals(value)) {
52          return true;
53        }
54      }
55      return false;
56    }
57  
58    public static void encodeChildren(FacesContext facesContext, UIComponent panel) throws IOException {
59      Deprecation.LOG.warn("Using deprecated API");
60      RenderUtils.encodeChildren(facesContext, panel);
61    }
62  
63    public static void encodeChildrenWithoutLayout(FacesContext facesContext, UIComponent container) throws IOException {
64      Deprecation.LOG.warn("Using deprecated API");
65      for (UIComponent child : container.getChildren()) {
66        encode(facesContext, child);
67      }
68    }
69  
70    public static void encode(FacesContext facesContext, UIComponent component) throws IOException {
71      Deprecation.LOG.warn("Using deprecated API");
72      RenderUtils.encode(facesContext, component);
73    }
74  
75    public static void prepareRendererAll(FacesContext facesContext, UIComponent component) throws IOException {
76      Deprecation.LOG.warn("Using deprecated API");
77      RenderUtils.prepareRendererAll(facesContext, component);
78    }
79  
80    public static String addMenuCheckToggle(String clientId, String onClick) {
81      Deprecation.LOG.error("No longer supported");
82      return "alert('Using deprecated API. Please check log file.');";
83    }
84  
85    public static String getFormattedValue(FacesContext facesContext, UIComponent component) {
86      Deprecation.LOG.warn("Using deprecated API");
87      return RenderUtils.getFormattedValue(facesContext, component);
88    }
89  
90    // Copy from RendererBase
91    public static String getFormattedValue(FacesContext context, UIComponent component, Object currentValue)
92        throws ConverterException {
93      Deprecation.LOG.warn("Using deprecated API");
94      return RenderUtils.getFormattedValue(context, component, currentValue);
95    }
96  
97    public static Measure calculateStringWidth(FacesContext facesContext, UIComponent component, String text) {
98      Deprecation.LOG.warn("Using deprecated API");
99      return RenderUtils.calculateStringWidth(facesContext, component, text);
100   }
101 
102   public static Measure calculateStringWidth2(FacesContext facesContext, UIComponent component, String text) {
103     Deprecation.LOG.warn("Using deprecated API");
104     return RenderUtils.calculateStringWidth2(facesContext, component, text);
105   }
106 
107   public static List<SelectItem> getItemsToRender(javax.faces.component.UISelectOne component) {
108     return getItems(component);
109   }
110 
111   public static List<SelectItem> getItemsToRender(javax.faces.component.UISelectMany component) {
112     return getItems(component);
113   }
114 
115   public static List<SelectItem> getItems(javax.faces.component.UIInput component) {
116     Deprecation.LOG.warn("Using deprecated API");
117     return RenderUtils.getItems(component);
118   }
119 
120   public static String currentValue(UIComponent component) {
121     Deprecation.LOG.warn("Using deprecated API");
122     return RenderUtils.currentValue(component);
123   }
124 
125   public static List<SelectItem> getSelectItems(UIComponent component) {
126     Deprecation.LOG.warn("Using deprecated API");
127     return RenderUtils.getSelectItems(component);
128   }
129 }