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.internal.component;
21  
22  import org.apache.myfaces.tobago.component.OnComponentCreated;
23  import org.apache.myfaces.tobago.component.TreeModelBuilder;
24  import org.apache.myfaces.tobago.internal.util.Deprecation;
25  import org.apache.myfaces.tobago.model.MixedTreeModel;
26  
27  import javax.el.ValueExpression;
28  import javax.faces.component.NamingContainer;
29  import javax.faces.component.UIComponent;
30  import javax.faces.context.FacesContext;
31  
32  /**
33   * @deprecated since 2.0.0
34   */
35  @Deprecated
36  public abstract class AbstractUITreeData extends javax.faces.component.UIInput
37      implements NamingContainer, TreeModelBuilder, OnComponentCreated {
38  
39    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.TreeData";
40  
41    private String var;
42  
43    /**
44     * Patch for backward compatibility.
45     */
46    public void onComponentCreated(FacesContext facesContext, UIComponent parent) {
47      Deprecation.LOG.warn("Please not use the <tc:treeData> tag.");
48      if (parent instanceof AbstractUITree) {
49        ValueExpression ve = getValueExpression("var");
50        if (ve != null) {
51          parent.setValueExpression("var", ve);
52        } else {
53          ((AbstractUITree) parent).setVar(getVar());
54        }
55      }
56  
57      if (parent instanceof AbstractUITree) {
58        ValueExpression ve = getValueExpression("value");
59        if (ve != null) {
60          parent.setValueExpression("value", ve);
61        } else {
62          ((AbstractUITree) parent).setValue(getValue());
63        }
64      }
65    }
66  
67    public String getVar() {
68      return var;
69    }
70  
71    public void setVar(String var) {
72      this.var = var;
73    }
74  
75    public void restoreState(FacesContext context, Object componentState) {
76      Object[] values = (Object[]) componentState;
77      super.restoreState(context, values[0]);
78      var = (String) values[1];
79    }
80  
81    public Object saveState(FacesContext context) {
82      Object[] values = new Object[2];
83      values[0] = super.saveState(context);
84      values[1] = var;
85      return values;
86    }
87  
88    /**
89     * @deprecated since 2.0.0
90     */
91    @Deprecated
92    public void buildTreeModelBegin(FacesContext facesContext, MixedTreeModel model) {
93      Deprecation.LOG.error("Doesn't work anymore.");
94    }
95  
96    /**
97     * @deprecated since 2.0.0
98     */
99    @Deprecated
100   public void buildTreeModelChildren(FacesContext facesContext, MixedTreeModel model) {
101     Deprecation.LOG.error("Doesn't work anymore.");
102   }
103 
104   /**
105    * @deprecated since 2.0.0
106    */
107   @Deprecated
108   public void buildTreeModelEnd(FacesContext facesContext, MixedTreeModel model) {
109     Deprecation.LOG.error("Doesn't work anymore.");
110   }
111 }