Coverage Report - org.apache.myfaces.view.facelets.tag.jsf.html.HtmlOutputScriptHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
HtmlOutputScriptHandler
0%
0/17
0%
0/10
3
 
 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:outputScript",
 42  
         componentClass = "org.apache.myfaces.view.facelets.tag.jsf.html._HtmlOutputScript")
 43  
 public class HtmlOutputScriptHandler extends HtmlComponentHandler implements RelocatableResourceHandler
 44  
 {
 45  
 
 46  
     public HtmlOutputScriptHandler(ComponentConfig config)
 47  
     {
 48  0
         super(config);
 49  0
     }
 50  
 
 51  
     public UIComponent findChildByTagId(FaceletContext ctx, UIComponent parent,
 52  
             String id)
 53  
     {
 54  
         //Script with no target and no relocation is possible
 55  0
         UIComponent c = ComponentSupport.findChildByTagId(parent, id);
 56  0
         if (c == null)
 57  
         {
 58  0
             UIViewRoot root = ComponentSupport.getViewRoot(ctx, parent);
 59  
             
 60  0
             if (root.getFacetCount() > 0)
 61  
             {
 62  0
                 Iterator<UIComponent> itr = root.getFacets().values().iterator();
 63  0
                 while (itr.hasNext() && c == null)
 64  
                 {
 65  0
                     UIComponent facet = itr.next();
 66  0
                     c = ComponentSupport.findChildByTagId(facet, id);
 67  0
                 }
 68  
             }
 69  0
             return c;
 70  
         }
 71  
         else
 72  
         {
 73  0
             return c;
 74  
         }
 75  
     }
 76  
 
 77  
 
 78  
     @Override
 79  
     public void onComponentCreated(FaceletContext ctx, UIComponent c,
 80  
             UIComponent parent)
 81  
     {
 82  0
         UIComponent parentCompositeComponent
 83  
                 = FaceletCompositionContext.getCurrentInstance(ctx).getCompositeComponentFromStack();
 84  0
         if (parentCompositeComponent != null)
 85  
         {
 86  0
             c.getAttributes().put(CompositeComponentELUtils.LOCATION_KEY,
 87  
                     parentCompositeComponent.getAttributes().get(CompositeComponentELUtils.LOCATION_KEY));
 88  
         }
 89  0
     }
 90  
 }