Coverage Report - org.seasar.teeda.core.render.html.HtmlPanelGroupRenderer
 
Classes in this File Line Coverage Branch Coverage Complexity
HtmlPanelGroupRenderer
100%
33/33
100%
10/10
2
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.teeda.core.render.html;
 17  
 
 18  
 import java.io.IOException;
 19  
 
 20  
 import javax.faces.component.UIComponent;
 21  
 import javax.faces.component.html.HtmlPanelGroup;
 22  
 import javax.faces.context.FacesContext;
 23  
 import javax.faces.context.ResponseWriter;
 24  
 import javax.faces.internal.IgnoreAttribute;
 25  
 
 26  
 import org.seasar.teeda.core.JsfConstants;
 27  
 import org.seasar.teeda.core.render.AbstractRenderer;
 28  
 import org.seasar.teeda.core.util.RendererUtil;
 29  
 
 30  
 /**
 31  
  * @author manhole
 32  
  */
 33  36
 public class HtmlPanelGroupRenderer extends AbstractRenderer {
 34  
 
 35  
     public static final String COMPONENT_FAMILY = "javax.faces.Panel";
 36  
 
 37  
     public static final String RENDERER_TYPE = "javax.faces.Group";
 38  
 
 39  36
     private final IgnoreAttribute ignoreComponent = new IgnoreAttribute();
 40  
     {
 41  36
         ignoreComponent.addAttributeName(JsfConstants.ID_ATTR);
 42  36
     }
 43  
 
 44  
     public void encodeBegin(FacesContext context, UIComponent component)
 45  
             throws IOException {
 46  16
         assertNotNull(context, component);
 47  14
         if (!component.isRendered()) {
 48  1
             return;
 49  
         }
 50  13
         encodeHtmlPanelGroupBegin(context, (HtmlPanelGroup) component);
 51  13
     }
 52  
 
 53  
     protected void encodeHtmlPanelGroupBegin(FacesContext context,
 54  
             HtmlPanelGroup htmlPanelGroup) throws IOException {
 55  13
         if (isWriteSpan(htmlPanelGroup)) {
 56  4
             ResponseWriter writer = context.getResponseWriter();
 57  4
             writer.startElement(JsfConstants.SPAN_ELEM, htmlPanelGroup);
 58  4
             RendererUtil.renderIdAttributeIfNecessary(writer, htmlPanelGroup,
 59  
                     getIdForRender(context, htmlPanelGroup));
 60  4
             renderRemainAttributes(htmlPanelGroup, writer, ignoreComponent);
 61  
         }
 62  13
     }
 63  
 
 64  
     private boolean isWriteSpan(HtmlPanelGroup htmlPanelGroup) {
 65  25
         return containsAttributeForRender(htmlPanelGroup, ignoreComponent);
 66  
     }
 67  
 
 68  
     public void encodeChildren(FacesContext context, UIComponent component)
 69  
             throws IOException {
 70  15
         assertNotNull(context, component);
 71  13
         if (!component.isRendered()) {
 72  1
             return;
 73  
         }
 74  12
         encodeHtmlPanelGroupChildren(context, (HtmlPanelGroup) component);
 75  12
     }
 76  
 
 77  
     protected void encodeHtmlPanelGroupChildren(FacesContext context,
 78  
             HtmlPanelGroup htmlPanelGroup) throws IOException {
 79  12
         encodeDescendantComponent(context, htmlPanelGroup);
 80  12
     }
 81  
 
 82  
     public void encodeEnd(FacesContext context, UIComponent component)
 83  
             throws IOException {
 84  15
         assertNotNull(context, component);
 85  13
         if (!component.isRendered()) {
 86  1
             return;
 87  
         }
 88  12
         encodeHtmlPanelGroupEnd(context, (HtmlPanelGroup) component);
 89  12
     }
 90  
 
 91  
     protected void encodeHtmlPanelGroupEnd(FacesContext context,
 92  
             HtmlPanelGroup htmlPanelGroup) throws IOException {
 93  12
         if (isWriteSpan(htmlPanelGroup)) {
 94  4
             ResponseWriter writer = context.getResponseWriter();
 95  4
             writer.endElement(JsfConstants.SPAN_ELEM);
 96  
         }
 97  12
     }
 98  
 
 99  
     public boolean getRendersChildren() {
 100  14
         return true;
 101  
     }
 102  
 
 103  
 }