Coverage Report - org.apache.tapestry5.corelib.mixins.NotEmpty
 
Classes in this File Line Coverage Branch Coverage Complexity
NotEmpty
100%
7/7
100%
2/2
0
 
 1  
 // Copyright 2009 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry5.corelib.mixins;
 16  
 
 17  
 import org.apache.tapestry5.MarkupWriter;
 18  
 import org.apache.tapestry5.annotations.MixinAfter;
 19  
 import org.apache.tapestry5.dom.Element;
 20  
 
 21  
 /**
 22  
  * A mixin that attaches to an element that renders an element.  At the end of the render, if the element is empty, then
 23  
  * a non-breaking space ( ) is injected into the element. This is often necessary for proper rendering on the
 24  
  * client.
 25  
  * <p/>
 26  
  * Often used in conjunction with the {@link org.apache.tapestry5.corelib.components.Any} component.
 27  
  *
 28  
  * @since 5.1.0.0
 29  
  */
 30  
 @MixinAfter
 31  61
 public class NotEmpty
 32  
 {
 33  
     private Element element;
 34  
 
 35  
     void beginRender(MarkupWriter writer)
 36  
     {
 37  9788
         element = writer.getElement();
 38  9788
     }
 39  
 
 40  
     void afterRender()
 41  
     {
 42  9788
         if (element.isEmpty())
 43  
         {
 44  190
             element.removeChildren();
 45  190
             element.raw("&nbsp;");
 46  
         }
 47  9788
     }
 48  
 }