Coverage Report - javax.faces.webapp.AttributeTag
 
Classes in this File Line Coverage Branch Coverage Complexity
AttributeTag
0%
0/31
0%
0/12
2.667
 
 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  
 package javax.faces.webapp;
 20  
 
 21  
 import javax.faces.component.UIComponent;
 22  
 import javax.faces.context.FacesContext;
 23  
 import javax.faces.el.ValueBinding;
 24  
 import javax.servlet.jsp.JspException;
 25  
 import javax.servlet.jsp.tagext.Tag;
 26  
 import javax.servlet.jsp.tagext.TagSupport;
 27  
 
 28  
 /**
 29  
  * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
 30  
  * @deprecated the implementation of this clazz is now an implementation detail.
 31  
  * @author Manfred Geiler (latest modification by $Author: skitching $)
 32  
  * @version $Revision: 676298 $ $Date: 2008-07-13 05:31:48 -0500 (Sun, 13 Jul 2008) $
 33  
  */
 34  0
 public class AttributeTag
 35  
         extends TagSupport
 36  
 {
 37  
     private static final long serialVersionUID = 3147657100171678632L;
 38  
     private String _name;
 39  
     private String _value;
 40  
 
 41  
     /**
 42  
      * @deprecated
 43  
      * @param name
 44  
      */
 45  
     public void setName(String name)
 46  
     {
 47  0
         _name = name;
 48  0
     }
 49  
 
 50  
     /**
 51  
      * @deprecated
 52  
      * @param value
 53  
      */
 54  
     public void setValue(String value)
 55  
     {
 56  0
         _value = value;
 57  0
     }
 58  
 
 59  
     /**
 60  
      * @deprecated
 61  
      */
 62  
     public int doStartTag() throws JspException
 63  
     {
 64  0
         UIComponentTag componentTag = UIComponentTag.getParentUIComponentTag(pageContext);
 65  0
         if (componentTag == null)
 66  
         {
 67  0
             throw new JspException("no parent UIComponentTag found");
 68  
         }
 69  0
         UIComponent component = componentTag.getComponentInstance();
 70  0
         if (component == null)
 71  
         {
 72  0
             throw new JspException("parent UIComponentTag has no UIComponent");
 73  
         }
 74  0
         String name = getName();
 75  0
         if (component.getAttributes().get(name) == null)
 76  
         {
 77  0
             Object value = getValue();
 78  
 
 79  0
             if(value != null)
 80  0
                 component.getAttributes().put(name, value);
 81  
         }
 82  0
         return Tag.SKIP_BODY;
 83  
     }
 84  
 
 85  
     /**
 86  
      * @deprecated
 87  
      */
 88  
     public void release()
 89  
     {
 90  0
         super.release();
 91  0
         _name = null;
 92  0
         _value = null;
 93  0
     }
 94  
 
 95  
 
 96  
     private String getName()
 97  
     {
 98  0
         if (UIComponentTag.isValueReference(_name))
 99  
         {
 100  0
             FacesContext facesContext = FacesContext.getCurrentInstance();
 101  0
             ValueBinding vb = facesContext.getApplication().createValueBinding(_name);
 102  0
             return (String)vb.getValue(facesContext);
 103  
         }
 104  
         
 105  0
         return _name;
 106  
     }
 107  
 
 108  
     private Object getValue()
 109  
     {
 110  0
         if (UIComponentTag.isValueReference(_value))
 111  
         {
 112  0
             FacesContext facesContext = FacesContext.getCurrentInstance();
 113  0
             ValueBinding vb = facesContext.getApplication().createValueBinding(_value);
 114  0
             return vb.getValue(facesContext);
 115  
         }
 116  
         
 117  0
         return _value;
 118  
     }
 119  
 
 120  
 }