Coverage Report - javax.faces.webapp.ConverterTag
 
Classes in this File Line Coverage Branch Coverage Complexity
ConverterTag
0%
0/35
0%
0/16
3.333
 
 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.application.Application;
 22  
 import javax.faces.component.UIComponent;
 23  
 import javax.faces.component.ValueHolder;
 24  
 import javax.faces.context.FacesContext;
 25  
 import javax.faces.convert.Converter;
 26  
 import javax.faces.el.ValueBinding;
 27  
 import javax.servlet.jsp.JspException;
 28  
 import javax.servlet.jsp.tagext.Tag;
 29  
 import javax.servlet.jsp.tagext.TagSupport;
 30  
 
 31  
 /**
 32  
  * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
 33  
  * 
 34  
  * @deprecated replaced by {@link ConverterELTag}
 35  
  */
 36  
 public class ConverterTag extends TagSupport
 37  
 {
 38  
     private static final long serialVersionUID = -6168345066829108081L;
 39  
     private String _converterId;
 40  
     private String _binding;
 41  
 
 42  
     public ConverterTag()
 43  
     {
 44  0
         super();
 45  0
     }
 46  
 
 47  
     public void setConverterId(String converterId)
 48  
     {
 49  0
         _converterId = converterId;
 50  0
     }
 51  
 
 52  
     @Override
 53  
     public int doStartTag() throws JspException
 54  
     {
 55  
 
 56  0
         UIComponentClassicTagBase componentTag =
 57  
                 UIComponentClassicTagBase.getParentUIComponentClassicTagBase(pageContext);
 58  
 
 59  0
         if (componentTag == null)
 60  
         {
 61  0
             throw new JspException("no parent UIComponentTag found");
 62  
         }
 63  0
         if (!componentTag.getCreated())
 64  
         {
 65  0
             return Tag.SKIP_BODY;
 66  
         }
 67  
 
 68  0
         Converter converter = createConverter();
 69  
 
 70  0
         UIComponent component = componentTag.getComponentInstance();
 71  0
         if (component == null)
 72  
         {
 73  0
             throw new JspException("parent UIComponentTag has no UIComponent");
 74  
         }
 75  0
         if (!(component instanceof ValueHolder))
 76  
         {
 77  0
             throw new JspException("UIComponent is no ValueHolder");
 78  
         }
 79  0
         ((ValueHolder)component).setConverter(converter);
 80  
 
 81  0
         return Tag.SKIP_BODY;
 82  
     }
 83  
 
 84  
     @Override
 85  
     public void release()
 86  
     {
 87  0
         super.release();
 88  0
         _converterId = null;
 89  0
         _binding = null;
 90  0
     }
 91  
 
 92  
     /**
 93  
      * @throws JspException  
 94  
      */
 95  
     protected Converter createConverter() throws JspException
 96  
     {
 97  0
         FacesContext facesContext = FacesContext.getCurrentInstance();
 98  0
         Application application = facesContext.getApplication();
 99  
 
 100  0
         if (_binding != null)
 101  
         {
 102  0
             ValueBinding vb = application.createValueBinding(_binding);
 103  0
             if (vb != null)
 104  
             {
 105  0
                 Converter converter = (Converter)vb.getValue(facesContext);
 106  0
                 if (converter != null)
 107  
                 {
 108  0
                     return converter;
 109  
                 }
 110  
             }
 111  
         }
 112  
 
 113  0
         if (UIComponentTag.isValueReference(_converterId))
 114  
         {
 115  0
             ValueBinding vb = facesContext.getApplication().createValueBinding(_converterId);
 116  0
             return application.createConverter((String)vb.getValue(facesContext));
 117  
         }
 118  
 
 119  0
         return application.createConverter(_converterId);
 120  
 
 121  
     }
 122  
 
 123  
     /**
 124  
      * @throws JspException  
 125  
      */
 126  
     public void setBinding(String binding) throws JspException
 127  
     {
 128  0
         _binding = binding;
 129  0
     }
 130  
 }