Coverage Report - org.apache.myfaces.view.facelets.tag.composite.InsertChildrenHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
InsertChildrenHandler
0%
0/15
0%
0/6
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.composite;
 20  
 
 21  
 import java.io.IOException;
 22  
 import java.util.logging.Level;
 23  
 import java.util.logging.Logger;
 24  
 
 25  
 import javax.faces.component.UIComponent;
 26  
 import javax.faces.view.facelets.FaceletContext;
 27  
 import javax.faces.view.facelets.TagConfig;
 28  
 import javax.faces.view.facelets.TagHandler;
 29  
 
 30  
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
 31  
 import org.apache.myfaces.view.facelets.AbstractFaceletContext;
 32  
 import org.apache.myfaces.view.facelets.FaceletCompositionContext;
 33  
 import org.apache.myfaces.view.facelets.tag.ComponentContainerHandler;
 34  
 
 35  
 /**
 36  
  * @author Leonardo Uribe (latest modification by $Author$)
 37  
  * @version $Revision$ $Date$
 38  
  */
 39  
 @JSFFaceletTag(name="composite:insertChildren")
 40  
 public class InsertChildrenHandler extends TagHandler implements ComponentContainerHandler
 41  
 {
 42  
     public static final String INSERT_CHILDREN_USED = "org.apache.myfaces.INSERT_CHILDREN_USED";
 43  
     
 44  0
     private static final Logger log = Logger.getLogger(InsertChildrenHandler.class.getName());
 45  
 
 46  
     public InsertChildrenHandler(TagConfig config)
 47  
     {
 48  0
         super(config);
 49  0
     }
 50  
 
 51  
     public void apply(FaceletContext ctx, UIComponent parent)
 52  
             throws IOException
 53  
     {
 54  0
         UIComponent parentCompositeComponent
 55  
                 = FaceletCompositionContext.getCurrentInstance(ctx).getCompositeComponentFromStack();
 56  
         
 57  0
         AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
 58  
 
 59  0
         if (actx.isBuildingCompositeComponentMetadata())
 60  
         {
 61  0
             CompositeComponentBeanInfo beanInfo = 
 62  
                 (CompositeComponentBeanInfo) parentCompositeComponent.getAttributes()
 63  
                 .get(UIComponent.BEANINFO_KEY);
 64  
             
 65  0
             if (beanInfo == null)
 66  
             {
 67  0
                 if (log.isLoggable(Level.SEVERE))
 68  
                 {
 69  0
                     log.severe("Cannot find composite bean descriptor UIComponent.BEANINFO_KEY ");
 70  
                 }
 71  0
                 return;
 72  
             }
 73  
             
 74  0
             beanInfo.getBeanDescriptor().setValue(INSERT_CHILDREN_USED, Boolean.TRUE);
 75  0
         }
 76  
         else
 77  
         {
 78  0
             actx.includeCompositeComponentDefinition(parent, null);
 79  
         }
 80  0
     }
 81  
 
 82  
 }