Coverage Report - org.apache.myfaces.shared_impl.renderkit.html.HtmlGroupRendererBase
 
Classes in this File Line Coverage Branch Coverage Complexity
HtmlGroupRendererBase
0%
0/21
0%
0/10
1.75
 
 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.renderkit.html;
 20  
 
 21  
 import org.apache.myfaces.shared_impl.renderkit.RendererUtils;
 22  
 
 23  
 import javax.faces.component.UIComponent;
 24  
 import javax.faces.component.UIViewRoot;
 25  
 import javax.faces.component.html.HtmlPanelGroup;
 26  
 import javax.faces.context.FacesContext;
 27  
 import javax.faces.context.ResponseWriter;
 28  
 import java.io.IOException;
 29  
 
 30  
 /**
 31  
  * @author Martin Marinschek
 32  
  * @version $Revision: $ $Date: $
 33  
  *          <p/>
 34  
  *          $Log: $
 35  
  */
 36  0
 public class HtmlGroupRendererBase
 37  
         extends HtmlRenderer 
 38  
 {
 39  
     private static final String LAYOUT_BLOCK_VALUE = "block";
 40  
 
 41  
     public boolean getRendersChildren()
 42  
     {
 43  0
         return true;
 44  
     }
 45  
 
 46  
     public void encodeBegin(FacesContext context, UIComponent component)
 47  
             throws IOException
 48  
     {
 49  0
     }
 50  
 
 51  
     public void encodeChildren(FacesContext context, UIComponent component)
 52  
         throws IOException
 53  
     {
 54  0
     }
 55  
 
 56  
     public void encodeEnd(FacesContext context, UIComponent component)
 57  
             throws IOException
 58  
     {
 59  0
         ResponseWriter writer = context.getResponseWriter();
 60  0
         boolean span = false;
 61  
 
 62  
         // will be SPAN or DIV, depending on the layout attribute value
 63  0
         String layoutElement = HTML.SPAN_ELEM;
 64  
 
 65  0
         HtmlPanelGroup panelGroup = (HtmlPanelGroup) component;
 66  
 
 67  
         // if layout is 'block', render DIV instead SPAN
 68  0
         String layout = panelGroup.getLayout();
 69  0
         if (layout != null && layout.equals(LAYOUT_BLOCK_VALUE))
 70  
         {
 71  0
             layoutElement = HTML.DIV_ELEM;
 72  
         }
 73  
 
 74  0
         if(component.getId()!=null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
 75  
         {
 76  0
             span = true;
 77  
 
 78  0
             writer.startElement(layoutElement, component);
 79  
 
 80  0
             HtmlRendererUtils.writeIdIfNecessary(writer, component, context);
 81  
 
 82  0
             HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES);
 83  
         }
 84  
         else
 85  
         {
 86  0
             span=HtmlRendererUtils.renderHTMLAttributesWithOptionalStartElement(writer,
 87  
                                                                              component,
 88  
                                                                              layoutElement,
 89  
                                                                              HTML.COMMON_PASSTROUGH_ATTRIBUTES);
 90  
         }
 91  
 
 92  0
         RendererUtils.renderChildren(context, component);
 93  0
         if (span)
 94  
         {
 95  0
             writer.endElement(layoutElement);
 96  
         }
 97  0
     }
 98  
 
 99  
 }