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(final Object[] list, final Object value) {
46      Deprecation.LOG.warn("Using deprecated API");
47      if (list == null) {
48        return false;
49      }
50      for (final 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(final FacesContext facesContext, final UIComponent panel) throws IOException {
59      Deprecation.LOG.warn("Using deprecated API");
60      RenderUtils.encodeChildren(facesContext, panel);
61    }
62  
63    public static void encodeChildrenWithoutLayout(final FacesContext facesContext, final UIComponent container)
64        throws IOException {
65      Deprecation.LOG.warn("Using deprecated API");
66      for (final UIComponent child : container.getChildren()) {
67        encode(facesContext, child);
68      }
69    }
70  
71    public static void encode(final FacesContext facesContext, final UIComponent component) throws IOException {
72      Deprecation.LOG.warn("Using deprecated API");
73      RenderUtils.encode(facesContext, component);
74    }
75  
76    public static void prepareRendererAll(final FacesContext facesContext, final UIComponent component)
77        throws IOException {
78      Deprecation.LOG.warn("Using deprecated API");
79      RenderUtils.prepareRendererAll(facesContext, component);
80    }
81  
82    public static String addMenuCheckToggle(final String clientId, final String onClick) {
83      Deprecation.LOG.error("No longer supported");
84      return "alert('Using deprecated API. Please check log file.');";
85    }
86  
87    public static String getFormattedValue(final FacesContext facesContext, final UIComponent component) {
88      Deprecation.LOG.warn("Using deprecated API");
89      return RenderUtils.getFormattedValue(facesContext, component);
90    }
91  
92    // Copy from RendererBase
93    public static String getFormattedValue(
94        final FacesContext context, final UIComponent component, final Object currentValue)
95        throws ConverterException {
96      Deprecation.LOG.warn("Using deprecated API");
97      return RenderUtils.getFormattedValue(context, component, currentValue);
98    }
99  
100   public static Measure calculateStringWidth(
101       final FacesContext facesContext, final UIComponent component, final String text) {
102     Deprecation.LOG.warn("Using deprecated API");
103     return RenderUtils.calculateStringWidth(facesContext, component, text);
104   }
105 
106   public static Measure calculateStringWidth2(
107       final FacesContext facesContext, final UIComponent component, final String text) {
108     Deprecation.LOG.warn("Using deprecated API");
109     return RenderUtils.calculateStringWidth2(facesContext, component, text);
110   }
111 
112   public static List<SelectItem> getItemsToRender(final javax.faces.component.UISelectOne component) {
113     return getItems(component);
114   }
115 
116   public static List<SelectItem> getItemsToRender(final javax.faces.component.UISelectMany component) {
117     return getItems(component);
118   }
119 
120   public static List<SelectItem> getItems(final javax.faces.component.UIInput component) {
121     Deprecation.LOG.warn("Using deprecated API");
122     return RenderUtils.getItems(component);
123   }
124 
125   public static String currentValue(final UIComponent component) {
126     Deprecation.LOG.warn("Using deprecated API");
127     return RenderUtils.currentValue(component);
128   }
129 
130   public static List<SelectItem> getSelectItems(final UIComponent component) {
131     Deprecation.LOG.warn("Using deprecated API");
132     return RenderUtils.getSelectItems(component);
133   }
134 }