public void apply()

in impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentDefinitionTagHandler.java [107:261]


    public void apply(FaceletContext ctx, UIComponent parent) throws IOException
    {
        FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(ctx);
        AbstractFaceletContext actx = (AbstractFaceletContext)ctx;
        UIComponent compositeBaseParent = actx.isBuildingCompositeComponentMetadata() ? parent : parent.getParent();
        
        // Store the current Location on the parent (the location is needed
        // to resolve the related composite component via #{cc} properly).
        if (_interfaceHandler != null)
        {
            if (!compositeBaseParent.getAttributes().containsKey(CompositeComponentELUtils.LOCATION_KEY))
            {
                compositeBaseParent.getAttributes()
                    .put(CompositeComponentELUtils.LOCATION_KEY, this._interfaceHandler.getLocation());
            }
        }
        else if (_implementationHandler != null)
        {
            if (!compositeBaseParent.getAttributes().containsKey(CompositeComponentELUtils.LOCATION_KEY))
            {
                compositeBaseParent.getAttributes()
                    .put(CompositeComponentELUtils.LOCATION_KEY, this._implementationHandler.getLocation());
            }
        }
        
        // Only apply if we are building composite component metadata,
        // in other words we are calling ViewDeclarationLanguage.getComponentMetadata
        if (actx.isBuildingCompositeComponentMetadata())
        {
            CompositeComponentBeanInfo tempBeanInfo = 
                (CompositeComponentBeanInfo) compositeBaseParent.getAttributes()
                .get(UIComponent.BEANINFO_KEY);
            
            if (tempBeanInfo == null)
            {
                if (_cacheable)
                {
                    if (_cachedBeanInfo == null)
                    {
                        tempBeanInfo  = _createCompositeComponentMetadata(compositeBaseParent);
                        compositeBaseParent.getAttributes().put(UIComponent.BEANINFO_KEY, tempBeanInfo);
                        
                        try
                        {
                            mctx.pushCompositeComponentToStack(compositeBaseParent);
                            
                            // Store the ccLevel key here
                            if (!compositeBaseParent.getAttributes().containsKey(CompositeComponentELUtils.LEVEL_KEY))
                            {
                                compositeBaseParent.getAttributes()
                                    .put(CompositeComponentELUtils.LEVEL_KEY, mctx.getCompositeComponentLevel());
                            }

                            _nextHandler.apply(ctx, parent);
                            
                            Collection<String> declaredDefaultValues = null;
                            
                            for (PropertyDescriptor pd : tempBeanInfo.getPropertyDescriptors())
                            {
                                if (pd.getValue("default") != null)
                                {
                                    if (declaredDefaultValues  == null)
                                    {
                                        declaredDefaultValues = new ArrayList<String>();
                                    }
                                    declaredDefaultValues.add(pd.getName());
                                }
                            }
                            if (declaredDefaultValues == null)
                            {
                                declaredDefaultValues = Collections.emptyList();
                            }
                            tempBeanInfo.getBeanDescriptor().
                                    setValue(UIComponent.ATTRS_WITH_DECLARED_DEFAULT_VALUES, declaredDefaultValues);
                        }
                        finally
                        {
                            mctx.popCompositeComponentToStack();
                            
                            _cachedBeanInfo = tempBeanInfo;
                        }
                    }
                    else
                    {
                        // Put the cached instance, but in that case it is not necessary to call
                        // nextHandler
                        compositeBaseParent.getAttributes().put(UIComponent.BEANINFO_KEY, _cachedBeanInfo);
                    }
                }
                else
                {
                    tempBeanInfo = _createCompositeComponentMetadata(compositeBaseParent);
                    compositeBaseParent.getAttributes().put(UIComponent.BEANINFO_KEY, tempBeanInfo);
                    
                    try
                    {
                        mctx.pushCompositeComponentToStack(compositeBaseParent);
                        
                        // Store the ccLevel key here
                        if (!compositeBaseParent.getAttributes().containsKey(CompositeComponentELUtils.LEVEL_KEY))
                        {
                            compositeBaseParent.getAttributes()
                                .put(CompositeComponentELUtils.LEVEL_KEY, mctx.getCompositeComponentLevel());
                        }
                    
                        _nextHandler.apply(ctx, parent);
                        
                        Collection<String> declaredDefaultValues = null;
                        
                        for (PropertyDescriptor pd : tempBeanInfo.getPropertyDescriptors())
                        {
                            if (pd.getValue("default") != null)
                            {
                                if (declaredDefaultValues  == null)
                                {
                                    declaredDefaultValues = new ArrayList<String>();
                                }
                                declaredDefaultValues.add(pd.getName());
                            }
                        }
                        if (declaredDefaultValues == null)
                        {
                            declaredDefaultValues = Collections.emptyList();
                        }
                        tempBeanInfo.getBeanDescriptor().
                                setValue(UIComponent.ATTRS_WITH_DECLARED_DEFAULT_VALUES, declaredDefaultValues);
                    }
                    finally
                    {
                        mctx.popCompositeComponentToStack();
                    }
                }
            }
        }
        else
        {
            try
            {
                mctx.pushCompositeComponentToStack(compositeBaseParent);

                // Store the ccLevel key here
                if (!compositeBaseParent.getAttributes().containsKey(CompositeComponentELUtils.LEVEL_KEY))
                {
                    compositeBaseParent.getAttributes()
                        .put(CompositeComponentELUtils.LEVEL_KEY, mctx.getCompositeComponentLevel());
                }
            
                _nextHandler.apply(ctx, parent);
            }
            finally
            {
                mctx.popCompositeComponentToStack();
            }
        }
    }