Coverage Report - org.apache.myfaces.view.facelets.tag.jsf.html.HtmlOutputStylesheetHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
HtmlOutputStylesheetHandler
0%
0/15
0%
0/8
2.333
 
 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.view.facelets.tag.jsf.html;
 20  
 
 21  
 import java.util.Iterator;
 22  
 
 23  
 import javax.faces.component.UIComponent;
 24  
 import javax.faces.component.UIViewRoot;
 25  
 import javax.faces.view.facelets.ComponentConfig;
 26  
 import javax.faces.view.facelets.FaceletContext;
 27  
 
 28  
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
 29  
 import org.apache.myfaces.view.facelets.FaceletCompositionContext;
 30  
 import org.apache.myfaces.view.facelets.el.CompositeComponentELUtils;
 31  
 import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport;
 32  
 import org.apache.myfaces.view.facelets.tag.jsf.RelocatableResourceHandler;
 33  
 
 34  
 /**
 35  
  * 
 36  
  * @since 2.0
 37  
  * @author Leonardo Uribe (latest modification by $Author$)
 38  
  * @version $Revision$ $Date$
 39  
  */
 40  
 @JSFFaceletTag(
 41  
         name = "h:outputStylesheet",
 42  
         componentClass = "org.apache.myfaces.view.facelets.tag.jsf.html._HtmlOutputStylesheet")
 43  
 public class HtmlOutputStylesheetHandler extends HtmlComponentHandler implements RelocatableResourceHandler
 44  
 {
 45  
 
 46  
     public HtmlOutputStylesheetHandler(ComponentConfig config)
 47  
     {
 48  0
         super(config);
 49  0
     }
 50  
 
 51  
     public UIComponent findChildByTagId(FaceletContext ctx, UIComponent parent,
 52  
             String id)
 53  
     {
 54  0
         UIComponent c = null;
 55  0
         UIViewRoot root = ComponentSupport.getViewRoot(ctx, parent);
 56  0
         if (root.getFacetCount() > 0)
 57  
         {
 58  0
             Iterator<UIComponent> itr = root.getFacets().values().iterator();
 59  0
             while (itr.hasNext() && c == null)
 60  
             {
 61  0
                 UIComponent facet = itr.next();
 62  0
                 c = ComponentSupport.findChildByTagId(facet, id);
 63  0
             }
 64  
         }
 65  0
         return c;
 66  
     }
 67  
 
 68  
     @Override
 69  
     public void onComponentCreated(FaceletContext ctx, UIComponent c,
 70  
             UIComponent parent)
 71  
     {
 72  0
         UIComponent parentCompositeComponent
 73  
                 = FaceletCompositionContext.getCurrentInstance(ctx).getCompositeComponentFromStack();
 74  0
         if (parentCompositeComponent != null)
 75  
         {
 76  0
             c.getAttributes().put(CompositeComponentELUtils.LOCATION_KEY,
 77  
                     parentCompositeComponent.getAttributes().get(CompositeComponentELUtils.LOCATION_KEY));
 78  
         }
 79  0
     }
 80  
 
 81  
 }