Coverage Report - org.apache.myfaces.taglib.core.SubviewTag
 
Classes in this File Line Coverage Branch Coverage Complexity
SubviewTag
0%
0/20
0%
0/10
2.25
 
 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.taglib.core;
 20  
 
 21  
 import javax.faces.component.UIComponent;
 22  
 import javax.faces.component.UINamingContainer;
 23  
 import javax.faces.component.UIOutput;
 24  
 import javax.faces.context.FacesContext;
 25  
 import javax.faces.webapp.UIComponentELTag;
 26  
 
 27  
 import org.apache.myfaces.application.jsp.ServletViewResponseWrapper;
 28  
 
 29  
 /**
 30  
  * @author Thomas Spiegl (latest modification by $Author$)
 31  
  * @version $Revision$ $Date$
 32  
  */
 33  
 public class SubviewTag extends UIComponentELTag
 34  
 {
 35  
     public SubviewTag()
 36  
     {
 37  0
         super();
 38  0
     }
 39  
 
 40  
     @Override
 41  
     public String getComponentType()
 42  
     {
 43  0
         return UINamingContainer.COMPONENT_TYPE;
 44  
     }
 45  
 
 46  
     @Override
 47  
     public String getRendererType()
 48  
     {
 49  0
         return null;
 50  
     }
 51  
 
 52  
     /**
 53  
      * Creates a UIComponent from the BodyContent If a Subview is included via the <jsp:include> tag the corresponding
 54  
      * jsp is rendered with getServletContext().getRequestDispatcher("includedSite").include(request,response) and it is
 55  
      * possible that something was written to the Response direct. So is is necessary that the content of the wrapped
 56  
      * response is added to the componenttree.
 57  
      * 
 58  
      * @return UIComponent or null
 59  
      */
 60  
     @Override
 61  
     protected UIComponent createVerbatimComponentFromBodyContent()
 62  
     {
 63  0
         UIOutput component = (UIOutput)super.createVerbatimComponentFromBodyContent();
 64  0
         FacesContext facesContext = FacesContext.getCurrentInstance();
 65  0
         Object response = facesContext.getExternalContext().getResponse();
 66  
         String wrappedOutput;
 67  
 
 68  0
         if (response instanceof ServletViewResponseWrapper)
 69  
         {
 70  0
             ServletViewResponseWrapper wrappedResponse = (ServletViewResponseWrapper)response;
 71  0
             wrappedOutput = wrappedResponse.toString();
 72  0
             if (wrappedOutput != null && wrappedOutput.length() > 0)
 73  
             {
 74  0
                 String componentvalue = null;
 75  0
                 if (component != null)
 76  
                 {
 77  
                     // save the Value of the Bodycontent
 78  0
                     componentvalue = (String)component.getValue();
 79  
                 }
 80  0
                 component = super.createVerbatimComponent();
 81  0
                 if (componentvalue != null)
 82  
                 {
 83  0
                     component.setValue(wrappedOutput + componentvalue);
 84  
                 }
 85  
                 else
 86  
                 {
 87  0
                     component.setValue(wrappedOutput);
 88  
                 }
 89  0
                 wrappedResponse.reset();
 90  
             }
 91  
         }
 92  0
         return component;
 93  
     }
 94  
 
 95  
 }