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  
  * @author Manfred Geiler (latest modification by $Author: skitching $)
 35  
  * @version $Revision: 676298 $ $Date: 2008-07-13 05:31:48 -0500 (Sun, 13 Jul 2008) $
 36  
  * @deprecated replaced by {@link ConverterELTag}
 37  
  */
 38  
 public class ConverterTag
 39  
         extends TagSupport
 40  
 {
 41  
     private static final long serialVersionUID = -6168345066829108081L;
 42  
     private String _converterId;
 43  
     private String _binding;
 44  
 
 45  
     public ConverterTag()
 46  
     {
 47  0
         super();
 48  0
     }
 49  
 
 50  
     public void setConverterId(String converterId)
 51  
     {
 52  0
         _converterId = converterId;
 53  0
     }
 54  
 
 55  
     public int doStartTag()
 56  
             throws JspException
 57  
     {
 58  
 
 59  0
         UIComponentClassicTagBase componentTag = UIComponentClassicTagBase.getParentUIComponentClassicTagBase(pageContext);
 60  
 
 61  0
         if (componentTag == null)
 62  
         {
 63  0
             throw new JspException("no parent UIComponentTag found");
 64  
         }
 65  0
         if (!componentTag.getCreated())
 66  
         {
 67  0
             return Tag.SKIP_BODY;
 68  
         }
 69  
 
 70  0
         Converter converter = createConverter();
 71  
 
 72  0
         UIComponent component = componentTag.getComponentInstance();
 73  0
         if (component == null)
 74  
         {
 75  0
             throw new JspException("parent UIComponentTag has no UIComponent");
 76  
         }
 77  0
         if (!(component instanceof ValueHolder))
 78  
         {
 79  0
             throw new JspException("UIComponent is no ValueHolder");
 80  
         }
 81  0
         ((ValueHolder)component).setConverter(converter);
 82  
 
 83  0
         return Tag.SKIP_BODY;
 84  
     }
 85  
 
 86  
     public void release()
 87  
     {
 88  0
         super.release();
 89  0
         _converterId = null;
 90  0
         _binding = null;
 91  0
     }
 92  
 
 93  
     protected Converter createConverter()
 94  
             throws JspException
 95  
     {
 96  0
         FacesContext facesContext = FacesContext.getCurrentInstance();
 97  0
         Application application = facesContext.getApplication();
 98  
 
 99  0
         if(_binding != null) {
 100  0
             ValueBinding vb = application.createValueBinding(_binding);
 101  0
             if(vb != null) {
 102  0
                 Converter converter = (Converter) vb.getValue(facesContext);
 103  0
                 if(converter != null) {
 104  0
                     return converter;
 105  
                 }
 106  
             }
 107  
         }
 108  
 
 109  0
         if (UIComponentTag.isValueReference(_converterId))
 110  
         {
 111  0
             ValueBinding vb = facesContext.getApplication().createValueBinding(_converterId);
 112  0
             return application.createConverter((String)vb.getValue(facesContext));
 113  
         }
 114  
 
 115  0
         return application.createConverter(_converterId);
 116  
 
 117  
     }
 118  
 
 119  
     public void setBinding(String binding) throws javax.servlet.jsp.JspException
 120  
     {
 121  0
         _binding = binding;
 122  0
     }
 123  
 }