Coverage Report - org.apache.myfaces.shared_impl.taglib.UIComponentBodyTagBase
 
Classes in this File Line Coverage Branch Coverage Complexity
UIComponentBodyTagBase
0%
0/53
0%
0/14
1.529
 
 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 org.apache.myfaces.shared_impl.taglib;
 20  
 
 21  
 import org.apache.myfaces.shared_impl.renderkit.JSFAttr;
 22  
 import org.apache.myfaces.shared_impl.taglib.html.HtmlCommandLinkELTagBase;
 23  
 
 24  
 import org.apache.commons.logging.Log;
 25  
 import org.apache.commons.logging.LogFactory;
 26  
 
 27  
 import javax.faces.component.UIComponent;
 28  
 import javax.faces.webapp.UIComponentBodyTag;
 29  
 import javax.servlet.jsp.JspException;
 30  
 import javax.servlet.jsp.tagext.BodyContent;
 31  
 import java.io.IOException;
 32  
 import java.io.Reader;
 33  
 
 34  
 /**
 35  
  * @author Manfred Geiler (latest modification by $Author: cagatay $)
 36  
  * @version $Revision: 606793 $ $Date: 2007-12-25 10:20:46 -0500 (Tue, 25 Dec 2007) $
 37  
  * @deprecated use {@link UIComponentBodyELTagBase} instead
 38  
  */
 39  0
 public abstract class UIComponentBodyTagBase
 40  
         extends UIComponentBodyTag
 41  
 {
 42  0
     private static final Log log = LogFactory.getLog(UIComponentBodyTagBase.class);
 43  
 
 44  
     public int doEndTag() throws JspException
 45  
     {
 46  0
         if (log.isWarnEnabled())
 47  
         {
 48  0
             UIComponent component = getComponentInstance();
 49  0
             if (component != null &&
 50  
                 component.getRendersChildren() &&
 51  
                 !isBodyContentEmpty())
 52  
             {
 53  0
                 log.warn("Component with id '" + component.getClientId(getFacesContext()) +
 54  
                          "' (" + getClass().getName() +
 55  
                          " tag) and path : "+org.apache.myfaces.shared_impl.renderkit.RendererUtils.getPathToComponent(component)+"renders it's children, but has embedded JSP or HTML code. Use the <f:verbatim> tag for nested HTML. For comments use <%/* */%> style JSP comments instead of <!-- --> style HTML comments." +
 56  
                          "\n BodyContent:\n" + getBodyContent().getString().trim());
 57  
             }
 58  
         }
 59  0
         return super.doEndTag();
 60  
     }
 61  
 
 62  
     /**
 63  
      * TODO: Ignore <!-- --> comments
 64  
      */
 65  
     private boolean isBodyContentEmpty()
 66  
     {
 67  0
         BodyContent bodyContent = getBodyContent();
 68  0
         if (bodyContent == null)
 69  
         {
 70  0
             return true;
 71  
         }
 72  
         try
 73  
         {
 74  0
             Reader reader = bodyContent.getReader();
 75  
             int c;
 76  0
             while ((c = reader.read()) != -1)
 77  
             {
 78  0
                 if (!Character.isWhitespace((char)c))
 79  
                 {
 80  0
                     return false;
 81  
                 }
 82  
             }
 83  0
             return true;
 84  
         }
 85  0
         catch (IOException e)
 86  
         {
 87  0
             log.error("Error inspecting BodyContent", e);
 88  0
             return false;
 89  
         }
 90  
     }
 91  
 
 92  
     //-------- rest is identical to UIComponentTagBase ------------------
 93  
 
 94  
     //UIComponent attributes
 95  
     private String _forceId;
 96  0
     private String _forceIdIndex = "true";
 97  
 
 98  
     //Special UIComponent attributes (ValueHolder, ConvertibleValueHolder)
 99  
     private String _value;
 100  
     private String _converter;
 101  
     //attributes id, rendered and binding are handled by UIComponentTag
 102  
 
 103  
     protected void setProperties(UIComponent component)
 104  
     {
 105  0
         super.setProperties(component);
 106  
 
 107  0
         setBooleanProperty(component, JSFAttr.FORCE_ID_ATTR, _forceId);
 108  0
         setBooleanProperty(component, org.apache.myfaces.shared_impl.renderkit.JSFAttr.FORCE_ID_INDEX_ATTR, _forceIdIndex);
 109  
 
 110  
         //rendererType already handled by UIComponentTag
 111  
 
 112  0
         setValueProperty(component, _value);
 113  0
         setConverterProperty(component, _converter);
 114  0
     }
 115  
 
 116  
     /**
 117  
      * Sets the forceId attribute of the tag.  NOTE: Not every tag that extends this class will
 118  
      * actually make use of this attribute.  Check the TLD to see which components actually
 119  
      * implement it.
 120  
      *
 121  
      * @param aForceId The value of the forceId attribute.
 122  
      */
 123  
     public void setForceId(String aForceId)
 124  
     {
 125  0
         _forceId = aForceId;
 126  0
     }
 127  
 
 128  
     /**
 129  
      * Sets the forceIdIndex attribute of the tag.  NOTE: Not every tag that extends this class will
 130  
      * actually make use of this attribute.  Check the TLD to see which components actually implement it.
 131  
      *
 132  
      * @param aForceIdIndex The value of the forceIdIndex attribute.
 133  
      */
 134  
     public void setForceIdIndex(String aForceIdIndex)
 135  
     {
 136  0
         _forceIdIndex = aForceIdIndex;
 137  0
     }
 138  
 
 139  
     public void setValue(String value)
 140  
     {
 141  0
         _value = value;
 142  0
     }
 143  
 
 144  
     public void setConverter(String converter)
 145  
     {
 146  0
         _converter = converter;
 147  0
     }
 148  
 
 149  
 
 150  
 
 151  
     // sub class helpers
 152  
 
 153  
     protected void setIntegerProperty(UIComponent component, String propName, String value)
 154  
     {
 155  0
         UIComponentTagUtils.setIntegerProperty(getFacesContext(), component, propName, value);
 156  0
     }
 157  
 
 158  
     protected void setStringProperty(UIComponent component, String propName, String value)
 159  
     {
 160  0
         UIComponentTagUtils.setStringProperty(getFacesContext(), component, propName, value);
 161  0
     }
 162  
 
 163  
     protected void setBooleanProperty(UIComponent component, String propName, String value)
 164  
     {
 165  0
         UIComponentTagUtils.setBooleanProperty(getFacesContext(), component, propName, value);
 166  0
     }
 167  
 
 168  
     protected void setValueProperty(UIComponent component, String value)
 169  
     {
 170  0
         UIComponentTagUtils.setValueProperty(getFacesContext(), component, value);
 171  0
     }
 172  
 
 173  
     private void setConverterProperty(UIComponent component, String value)
 174  
     {
 175  0
         UIComponentTagUtils.setConverterProperty(getFacesContext(), component, value);
 176  0
     }
 177  
 
 178  
     protected void setValidatorProperty(UIComponent component, String value)
 179  
     {
 180  0
         UIComponentTagUtils.setValidatorProperty(getFacesContext(), component, value);
 181  0
     }
 182  
 
 183  
     protected void setActionProperty(UIComponent component, String action)
 184  
     {
 185  0
         UIComponentTagUtils.setActionProperty(getFacesContext(), component, action);
 186  0
     }
 187  
 
 188  
     protected void setActionListenerProperty(UIComponent component, String actionListener)
 189  
     {
 190  0
         UIComponentTagUtils.setActionListenerProperty(getFacesContext(), component, actionListener);
 191  0
     }
 192  
 
 193  
     protected void setValueChangedListenerProperty(UIComponent component, String valueChangedListener)
 194  
     {
 195  0
         UIComponentTagUtils.setValueChangedListenerProperty(getFacesContext(), component, valueChangedListener);
 196  0
     }
 197  
 
 198  
     protected void setValueBinding(UIComponent component,
 199  
                                    String propName,
 200  
                                    String value)
 201  
     {
 202  0
         UIComponentTagUtils.setValueBinding(getFacesContext(), component, propName, value);
 203  0
     }
 204  
 
 205  
 }