Coverage Report - org.apache.myfaces.shared_impl.taglib.UIComponentBodyELTagBase
 
Classes in this File Line Coverage Branch Coverage Complexity
UIComponentBodyELTagBase
0%
0/73
0%
0/14
0
 
 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.commons.logging.Log;
 22  
 import org.apache.commons.logging.LogFactory;
 23  
 
 24  
 import javax.el.MethodExpression;
 25  
 import javax.el.ValueExpression;
 26  
 import javax.faces.component.UIComponent;
 27  
 import javax.faces.webapp.UIComponentELTag;
 28  
 import javax.servlet.jsp.JspException;
 29  
 import javax.servlet.jsp.tagext.BodyContent;
 30  
 import java.io.IOException;
 31  
 import java.io.Reader;
 32  
 
 33  
 /**
 34  
  * @author Manfred Geiler (latest modification by $Author: skitching $)
 35  
  * @version $Revision: 673827 $ $Date: 2008-07-03 16:46:23 -0500 (Thu, 03 Jul 2008) $
 36  
  */
 37  0
 public abstract class UIComponentBodyELTagBase extends UIComponentELTag
 38  
 {
 39  0
     private static final Log log = LogFactory.getLog(UIComponentBodyTagBase.class);
 40  
 
 41  
     public int doEndTag() throws JspException
 42  
     {
 43  0
         if (log.isWarnEnabled())
 44  
         {
 45  0
             UIComponent component = getComponentInstance();
 46  0
             if (component != null &&
 47  
                 component.getRendersChildren() &&
 48  
                 !isBodyContentEmpty())
 49  
             {
 50  0
                 log.warn("Component with id '" + component.getClientId(getFacesContext()) +
 51  
                          "' (" + getClass().getName() +
 52  
                          " 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." +
 53  
                          "\n BodyContent:\n" + getBodyContent().getString().trim());
 54  
             }
 55  
         }
 56  0
         return super.doEndTag();
 57  
     }
 58  
 
 59  
     /**
 60  
      * TODO: Ignore <!-- --> comments
 61  
      */
 62  
     private boolean isBodyContentEmpty()
 63  
     {
 64  0
         BodyContent bodyContent = getBodyContent();
 65  0
         if (bodyContent == null)
 66  
         {
 67  0
             return true;
 68  
         }
 69  
         try
 70  
         {
 71  0
             Reader reader = bodyContent.getReader();
 72  
             int c;
 73  0
             while ((c = reader.read()) != -1)
 74  
             {
 75  0
                 if (!Character.isWhitespace((char)c))
 76  
                 {
 77  0
                     return false;
 78  
                 }
 79  
             }
 80  0
             return true;
 81  
         }
 82  0
         catch (IOException e)
 83  
         {
 84  0
             log.error("Error inspecting BodyContent", e);
 85  0
             return false;
 86  
         }
 87  
     }
 88  
 
 89  
     //-------- rest is identical to UIComponentTagBase ------------------
 90  
 
 91  
     //UIComponent attributes
 92  
     private ValueExpression _forceId;
 93  
     private ValueExpression _forceIdIndex;
 94  0
     private static final Boolean DEFAULT_FORCE_ID_INDEX_VALUE = Boolean.TRUE;
 95  
 
 96  
     //Special UIComponent attributes (ValueHolder, ConvertibleValueHolder)
 97  
     private ValueExpression _value;
 98  
     private ValueExpression _converter;
 99  
     //attributes id, rendered and binding are handled by UIComponentTag
 100  
 
 101  
     protected void setProperties(UIComponent component)
 102  
     {
 103  0
         super.setProperties(component);
 104  
 
 105  0
         setBooleanProperty(component, org.apache.myfaces.shared_impl.renderkit.JSFAttr.FORCE_ID_ATTR, _forceId);
 106  0
         setBooleanProperty(component, org.apache.myfaces.shared_impl.renderkit.JSFAttr.FORCE_ID_INDEX_ATTR, _forceIdIndex, DEFAULT_FORCE_ID_INDEX_VALUE);
 107  
 
 108  
         //rendererType already handled by UIComponentTag
 109  
 
 110  0
         setValueProperty(component, _value);
 111  0
         setConverterProperty(component, _converter);
 112  0
     }
 113  
 
 114  
     /**
 115  
      * Sets the forceId attribute of the tag.  NOTE: Not every tag that extends this class will
 116  
      * actually make use of this attribute.  Check the TLD to see which components actually
 117  
      * implement it.
 118  
      *
 119  
      * @param aForceId The value of the forceId attribute.
 120  
      */
 121  
     public void setForceId(ValueExpression aForceId)
 122  
     {
 123  0
         _forceId = aForceId;
 124  0
     }
 125  
 
 126  
     /**
 127  
      * Sets the forceIdIndex attribute of the tag.  NOTE: Not every tag that extends this class will
 128  
      * actually make use of this attribute.  Check the TLD to see which components actually implement it.
 129  
      *
 130  
      * @param aForceIdIndex The value of the forceIdIndex attribute.
 131  
      */
 132  
     public void setForceIdIndex(ValueExpression aForceIdIndex)
 133  
     {
 134  0
         _forceIdIndex = aForceIdIndex;
 135  0
     }
 136  
 
 137  
     public void setValue(ValueExpression value)
 138  
     {
 139  0
         _value = value;
 140  0
     }
 141  
 
 142  
     public void setConverter(ValueExpression converter)
 143  
     {
 144  0
         _converter = converter;
 145  0
     }
 146  
 
 147  
 
 148  
 
 149  
     // sub class helpers
 150  
     
 151  
     protected void setIntegerProperty(UIComponent component, String propName, ValueExpression value)
 152  
     {
 153  0
         UIComponentELTagUtils.setIntegerProperty(component, propName, value);
 154  0
     }
 155  
     
 156  
     @Deprecated
 157  
     protected void setIntegerProperty(UIComponent component, String propName, String value)
 158  
     {
 159  0
         UIComponentTagUtils.setIntegerProperty(getFacesContext(), component, propName, value);
 160  0
     }
 161  
     
 162  
     protected void setStringProperty(UIComponent component, String propName, ValueExpression value)
 163  
     {
 164  0
         UIComponentELTagUtils.setStringProperty(component, propName, value);
 165  0
     }
 166  
 
 167  
     @Deprecated
 168  
     protected void setStringProperty(UIComponent component, String propName, String value)
 169  
     {
 170  0
         UIComponentTagUtils.setStringProperty(getFacesContext(), component, propName, value);
 171  0
     }
 172  
     
 173  
     protected void setBooleanProperty(UIComponent component, String propName, ValueExpression value)
 174  
     {
 175  0
         UIComponentELTagUtils.setBooleanProperty(component, propName, value);
 176  0
     }
 177  
     
 178  
     protected void setBooleanProperty(UIComponent component, String propName, ValueExpression value, Boolean defaultValue)
 179  
     {
 180  0
         UIComponentELTagUtils.setBooleanProperty(component, propName, value, defaultValue);
 181  0
     }
 182  
 
 183  
     @Deprecated
 184  
     protected void setBooleanProperty(UIComponent component, String propName, String value)
 185  
     {
 186  0
         UIComponentTagUtils.setBooleanProperty(getFacesContext(), component, propName, value);
 187  0
     }
 188  
     
 189  
     private void setValueProperty(UIComponent component, ValueExpression value)
 190  
     {
 191  0
         UIComponentELTagUtils.setValueProperty(getFacesContext(), component, value);
 192  0
     }
 193  
 
 194  
     @Deprecated
 195  
     protected void setValueProperty(UIComponent component, String value)
 196  
     {
 197  0
         UIComponentTagUtils.setValueProperty(getFacesContext(), component, value);
 198  0
     }
 199  
     
 200  
     private void setConverterProperty(UIComponent component, ValueExpression value)
 201  
     {
 202  0
         UIComponentELTagUtils.setConverterProperty(getFacesContext(), component, value);
 203  0
     }
 204  
 
 205  
 
 206  
     @Deprecated
 207  
     private void setConverterProperty(UIComponent component, String value)
 208  
     {
 209  0
         UIComponentTagUtils.setConverterProperty(getFacesContext(), component, value);
 210  0
     }
 211  
     
 212  
     protected void addValidatorProperty(UIComponent component, MethodExpression value)
 213  
     {
 214  0
         UIComponentELTagUtils.addValidatorProperty(getFacesContext(), component, value);
 215  0
     }
 216  
 
 217  
     @Deprecated
 218  
     protected void setValidatorProperty(UIComponent component, String value)
 219  
     {
 220  0
         UIComponentTagUtils.setValidatorProperty(getFacesContext(), component, value);
 221  0
     }
 222  
     
 223  
     protected void setActionProperty(UIComponent component, MethodExpression action)
 224  
     {
 225  0
         UIComponentELTagUtils.setActionProperty(getFacesContext(), component, action);
 226  0
     }
 227  
 
 228  
     @Deprecated
 229  
     protected void setActionProperty(UIComponent component, String action)
 230  
     {
 231  0
         UIComponentTagUtils.setActionProperty(getFacesContext(), component, action);
 232  0
     }
 233  
     
 234  
     protected void setActionListenerProperty(UIComponent component, MethodExpression actionListener)
 235  
     {
 236  0
         UIComponentELTagUtils.addActionListenerProperty(getFacesContext(), component, actionListener);
 237  0
     }
 238  
 
 239  
     @Deprecated
 240  
     protected void setActionListenerProperty(UIComponent component, String actionListener)
 241  
     {
 242  0
         UIComponentTagUtils.setActionListenerProperty(getFacesContext(), component, actionListener);
 243  0
     }
 244  
     
 245  
     protected void addValueChangedListenerProperty(UIComponent component, MethodExpression valueChangedListener)
 246  
     {
 247  0
         UIComponentELTagUtils.addValueChangedListenerProperty(getFacesContext(), component, valueChangedListener);
 248  0
     }
 249  
 
 250  
     @Deprecated
 251  
     protected void setValueChangedListenerProperty(UIComponent component, String valueChangedListener)
 252  
     {
 253  0
         UIComponentTagUtils.setValueChangedListenerProperty(getFacesContext(), component, valueChangedListener);
 254  0
     }
 255  
 
 256  
     protected void setValueBinding(UIComponent component,
 257  
             String propName,
 258  
             ValueExpression value)
 259  
     {
 260  0
         UIComponentELTagUtils.setValueBinding(getFacesContext(), component, propName, value);
 261  0
     }
 262  
 
 263  
 }