Coverage Report - org.apache.myfaces.el.unified.resolver.implicitobject.CompositeComponentImplicitObject
 
Classes in this File Line Coverage Branch Coverage Complexity
CompositeComponentImplicitObject
0%
0/13
0%
0/6
1.6
 
 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.el.unified.resolver.implicitobject;
 20  
 
 21  
 import java.beans.FeatureDescriptor;
 22  
 import java.util.List;
 23  
 
 24  
 import javax.el.ELContext;
 25  
 import javax.faces.component.UIComponent;
 26  
 import javax.faces.context.FacesContext;
 27  
 
 28  
 import org.apache.myfaces.view.facelets.el.CompositeComponentELUtils;
 29  
 
 30  
 /**
 31  
  * Encapsulates information needed by the ImplicitObjectResolver
 32  
  * 
 33  
  * @author Leonardo Uribe (latest modification by $Author$)
 34  
  * @version $Revision$ $Date$
 35  
  */
 36  
 public class CompositeComponentImplicitObject extends ImplicitObject
 37  
 {
 38  
 
 39  
     private static final String NAME = "cc";
 40  
 
 41  
     /** Creates a new instance of CompositeComponentImplicitObjectImplicitObject */
 42  
     public CompositeComponentImplicitObject()
 43  0
     {
 44  0
     }
 45  
 
 46  
     @Override
 47  
     public Object getValue(ELContext context)
 48  
     {
 49  0
         FacesContext facesContext = facesContext(context);
 50  
         
 51  
         // Look for the attribute set by LocationValueExpression
 52  
         // or LocationMethodExpression on the FacesContext
 53  0
         List<UIComponent> list = (List<UIComponent>) facesContext.getAttributes()
 54  
                 .get(CompositeComponentELUtils.CURRENT_COMPOSITE_COMPONENT_KEY);
 55  
         
 56  0
         UIComponent cc = null;
 57  
         
 58  0
         if (list != null && !list.isEmpty())
 59  
         {
 60  0
             cc = list.get(list.size()-1);
 61  
         }
 62  0
         if (cc == null)
 63  
         {
 64  
             // take the composite component from the stack
 65  0
             cc = UIComponent.getCurrentCompositeComponent(facesContext(context));
 66  
         }
 67  0
         return cc;
 68  
     }
 69  
 
 70  
     @Override
 71  
     public String getName()
 72  
     {
 73  0
         return NAME;
 74  
     }
 75  
 
 76  
     @Override
 77  
     public Class<?> getType()
 78  
     {
 79  0
         return null;
 80  
     }
 81  
 
 82  
     @Override
 83  
     public FeatureDescriptor getDescriptor()
 84  
     {
 85  0
         return makeDescriptor(NAME,
 86  
                 "Represents the composite component most recently pushed using UIComponent.pushComponentToEL",
 87  
                 UIComponent.class);
 88  
     }
 89  
 }