Examples of FaceletCompositionContext


Examples of org.apache.myfaces.view.facelets.FaceletCompositionContext

            if (getFor() == null)
            {
                throw new TagException(_delegate.getTag(), "is nested inside a composite component"
                        + " but does not have a for attribute.");
            }
            FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(ctx);
            mctx.addAttachedObjectHandler(parent, _delegate);
        }
        else
        {
            throw new TagException(_delegate.getTag(),
                    "Parent not composite component or an instance of ValueHolder: " + parent);
View Full Code Here

Examples of org.apache.myfaces.view.facelets.FaceletCompositionContext

        {
            applyAttachedObject(ctx.getFacesContext(), parent);
        }
        else if (UIComponent.isCompositeComponent(parent))
        {
            FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(ctx);
            // It is supposed that for composite components, this tag should
            // add itself as a target, but note that on whole api does not exists
            // some tag that expose client behaviors as targets for composite
            // components. In RI, there exists a tag called composite:clientBehavior,
            // but does not appear on spec or javadoc, maybe because this could be
            // understand as an implementation detail, after all there exists a key
            // called AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY that could be
            // used to create a tag outside jsf implementation to attach targets.
            mctx.addAttachedObjectHandler(parent, _delegate);
        }
        else
        {
            throw new TagException(_delegate.getTag(),
                    "Parent not composite component or an instance of ClientBehaviorHolder: " + parent);
View Full Code Here

Examples of org.apache.myfaces.view.facelets.FaceletCompositionContext

    @Override
    public void apply(FaceletContext ctx, UIComponent parent) throws IOException
    {
        // we need methods from AbstractFaceletContext
        FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(ctx);

        if (_wrapMode)
        {
            // the tag has children --> provide validator information for all children
           
            // FIXME the spec says we should save the validation groups in an attribute
            // on the parent UIComponent, but this will be a problem in the following scenario:
            // <h:form>
            //     <f:validateBean>
            //         <h:inputText />
            //     </f:validateBean>
            //     <h:inputText />
            // </h:form>
            // because the validator would also be applied to the second h:inputText,
            // which it should not, on my opinion. In addition, mojarra also does not
            // attach the validator to the second h:inputText in this scenario (blackbox test).
            // So I use the same way as f:ajax for this problem. -=Jakob Korherr=-
           
            String validatorId = _delegate.getValidatorConfig().getValidatorId();
            /*
            boolean disabled = _delegate.isDisabled(ctx);
            if (disabled)
            {
                // the validator is disabled --> add its id to the exclusion stack
                boolean validatorIdAvailable = validatorId != null && !"".equals(validatorId);
                try
                {
                    if (validatorIdAvailable)
                    {
                        mctx.pushExcludedValidatorIdToStack(validatorId);
                    }
                    _delegate.getValidatorConfig().getNextHandler().apply(ctx, parent);
                }
                finally
                {
                    if (validatorIdAvailable)
                    {
                        mctx.popExcludedValidatorIdToStack();
                    }
                }
            }
            else
            {*/
                // the validator is enabled
                // --> add the validation groups and the validatorId to the stack
                //String groups = getValidationGroups(ctx);
                // spec: don't save the validation groups string if it is null or empty string
                //boolean groupsAvailable = groups != null
                        //&& !groups.matches(BeanValidator.EMPTY_VALIDATION_GROUPS_PATTERN);
                //try
                //{
                    //if (groupsAvailable)
                    //{
                    //    mctx.pushValidationGroupsToStack(groups);
                    //}
                    try
                    {
                        mctx.pushEnclosingValidatorIdToStack(validatorId, this);
                        _delegate.applyNextHandler(ctx, parent);
                    }
                    finally
                    {
                        mctx.popEnclosingValidatorIdToStack();
                    }
                //}
                //finally
                //{
                    //if (groupsAvailable)
                    //{
                        //mctx.popValidationGroupsToStack();
                    //}
                //}
            /*}*/
        }
        else
        {
            // Apply only if we are creating a new component
            if (!ComponentHandler.isNew(parent))
            {
                return;
            }

            // the tag is a leave --> attach validator to parent
            if (parent instanceof EditableValueHolder)
            {
                applyAttachedObject(ctx.getFacesContext(), parent);
            }
            else if (UIComponent.isCompositeComponent(parent))
            {
                if (getFor() == null)
                {
                    throw new TagException(_delegate.getTag(), "is nested inside a composite component"
                            + " but does not have a for attribute.");
                }
                mctx.addAttachedObjectHandler(parent, _delegate);
            }
            else
            {
                throw new TagException(_delegate.getTag(),
                        "Parent not composite component or an instance of EditableValueHolder: " + parent);
View Full Code Here

Examples of org.apache.myfaces.view.facelets.FaceletCompositionContext

    @Override
    public void applyNextHandler(FaceletContext ctx, UIComponent c)
            throws IOException
    {
        //super.applyNextHandler(ctx, c);
        FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(ctx);
       
        // Since JSF 2.2, there are two cases here:
        //
        // 1. The composite component content is defined as facelet content like usual.
        // 2. The composite component content will be defined programatically. That means,
        // once the component instance is created, the user will be responsible to add
        // children / facets and the code that process the composite component take effect
        // when the composite component is added to the view.
        if (mctx.isDynamicCompositeComponentHandler())
        {
            _dynamicCompositeComponent = true;
            try
            {
                mctx.setDynamicCompositeComponentHandler(false);
                // If the composite component needs to be created dynamically
                //
                Integer step = (Integer) c.getAttributes().get(CREATE_CC_ON_POST_ADD_TO_VIEW);
                if (step == null)
                {
                    // The flag is not found, so we are creating the component right now.
                    // Add the flag and return.
                    c.getAttributes().put(CREATE_CC_ON_POST_ADD_TO_VIEW, 0);
                }
                else if (step.intValue() == 0)
                {
                    // Should not happen, stop processing
                }
                else if (step.intValue() == 1)
                {
                    // The component was created, and the listener attached to PostAddToViewEvent
                    // is executing right now. Do the necessary steps to process the
                    // composite component dynamically.
                    applyNextHandlerIfNotAppliedDynamically(ctx, c);

                    applyCompositeComponentFacelet(ctx,c);

                    applyFinalInitializationSteps(ctx, mctx, c);

                    c.getAttributes().put(CREATE_CC_ON_POST_ADD_TO_VIEW, 2);
                }
                else
                {
                    // Refresh over dynamic composite component       
                    applyCompositeComponentFacelet(ctx,c);
                }
            }
            finally
            {
                mctx.setDynamicCompositeComponentHandler(true);
            }
        }
        else
        {
            applyNextHandlerIfNotApplied(ctx, c);
View Full Code Here

Examples of org.apache.myfaces.view.facelets.FaceletCompositionContext

    }
   
    protected void applyCompositeComponentFacelet(FaceletContext faceletContext, UIComponent compositeComponentBase)
        throws IOException
    {
        FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(faceletContext);
        AbstractFaceletContext actx = (AbstractFaceletContext) faceletContext;
        UIPanel compositeFacetPanel
                = (UIPanel) compositeComponentBase.getFacets().get(UIComponent.COMPOSITE_FACET_NAME);
        if (compositeFacetPanel == null)
        {
            compositeFacetPanel = (UIPanel)
                faceletContext.getFacesContext().getApplication().createComponent(
                    faceletContext.getFacesContext(), UIPanel.COMPONENT_TYPE, null);
            compositeFacetPanel.getAttributes().put(ComponentSupport.COMPONENT_ADDED_BY_HANDLER_MARKER,
                    Boolean.TRUE);
            compositeComponentBase.getFacets().put(UIComponent.COMPOSITE_FACET_NAME, compositeFacetPanel);
           
            // Set an id to the created facet component, to prevent id generation and make
            // partial state saving work without problem.
            UniqueIdVendor uniqueIdVendor = mctx.getUniqueIdVendorFromStack();
            if (uniqueIdVendor == null)
            {
                uniqueIdVendor = ComponentSupport.getViewRoot(faceletContext, compositeComponentBase);
            }
            if (uniqueIdVendor != null)
            {
                // UIViewRoot implements UniqueIdVendor, so there is no need to cast to UIViewRoot
                // and call createUniqueId()
                String uid = uniqueIdVendor.createUniqueId(faceletContext.getFacesContext(),
                        mctx.getSharedStringBuilder()
                        .append(compositeComponentBase.getId())
                        .append("__f_")
                        .append("cc_facet").toString());
                compositeFacetPanel.setId(uid);
            }           
        }
       
        // Before call applyCompositeComponent we need to add ajax behaviors
        // to the current compositeComponentBase. Note that super.applyNextHandler()
        // has already been called, but this point is before vdl.retargetAttachedObjects,
        // so we can't but this on ComponentTagHandlerDelegate, if we want this to be
        // applied correctly.
        Iterator<AjaxHandler> it = ((AbstractFaceletContext) faceletContext).getAjaxHandlers();
        if (it != null)
        {
            while(it.hasNext())
            {
                mctx.addAttachedObjectHandler(
                        compositeComponentBase, it.next());
            }
        }   
       
        VariableMapper orig = faceletContext.getVariableMapper();
View Full Code Here

Examples of org.apache.myfaces.view.facelets.FaceletCompositionContext

            throws IOException, FacesException, FaceletException, ELException
    {
        if (_dynamicCompositeComponent)
        {
            AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
            FaceletCompositionContext fcc = actx.getFaceletCompositionContext();
            UIComponent innerCompositeComponent = fcc.getCompositeComponentFromStack();
           
            // In a programatical addition, the code that process the composite component only takes effect
            // when the composite component is added to the view.
            Integer step = (Integer) innerCompositeComponent.getAttributes().get(CREATE_CC_ON_POST_ADD_TO_VIEW);
            if (step != null && step.intValue() == 1)
            {
                if (name != null)
                {
                    //1. Initialize map used to retrieve facets
                    if (innerCompositeComponent.getFacetCount() == 0)
                    {
                        checkFacetRequired(ctx, name);
                        return true;
                    }
                    UIComponent facet = innerCompositeComponent.getFacet(name);
                    if (facet != null)
                    {
                        // Insert facet
                        innerCompositeComponent.getFacets().remove(name);
                        parent.getFacets().put(name, facet);
                        return true;
                    }
                    else
                    {
                        checkFacetRequired(ctx, name);
                        return true;
                    }
                }
                else
                {
                    if (innerCompositeComponent.getChildCount() > 0)
                    {
                        String facetName = (String) parent.getAttributes().get(
                                org.apache.myfaces.view.facelets.tag.jsf.core.FacetHandler.KEY);
                        // Insert children
                        List<UIComponent> children = new ArrayList<UIComponent>(
                            innerCompositeComponent.getChildCount());
                        while (innerCompositeComponent.getChildCount() > 0)
                        {
                            children.add(innerCompositeComponent.getChildren().remove(0));
                        }
                        while (children.size() > 0)
                        {
                            UIComponent child = children.remove(0);
                            child.getAttributes().put(InsertChildrenHandler.INSERT_CHILDREN_USED,
                                    Boolean.TRUE);
                            if (facetName != null)
                            {
                                ComponentSupport.addFacet(ctx, parent, child, facetName);
                            }
                            else
                            {
                                parent.getChildren().add(child);
                            }
                        }
                    }
                    return true;
                }
            }
            else if (step != null && step.intValue() > 1)
            {
                // refresh case, in facet case it is not necessary to remove/add the facet, because there
                // is no relative order (it is always on the same spot).
                if (name == null)
                {
                    String facetName = (String) parent.getAttributes().get(
                            org.apache.myfaces.view.facelets.tag.jsf.core.FacetHandler.KEY);
                    // refresh case, remember the inserted children does not have any
                    // associated tag handler, so in this case we just need to remove and add them in the same order
                    // we found them
                    List<UIComponent> children = null;
                    if (facetName == null)
                    {
                        children = new ArrayList<UIComponent>(parent.getChildCount());
                        int i = 0;
                        while (parent.getChildCount()-i > 0)
                        {
                            UIComponent child = parent.getChildren().get(i);
                            if (Boolean.TRUE.equals(child.getAttributes().get(
                                    InsertChildrenHandler.INSERT_CHILDREN_USED)))
                            {
                                children.add(parent.getChildren().remove(i));
                            }
                            else
                            {
                                i++;
                            }
                        }
                    }
                    else
                    {
                        children = new ArrayList<UIComponent>();
                        UIComponent child = parent.getFacet(facetName);
                        if (Boolean.TRUE.equals(child.getAttributes().get(
                                    InsertChildrenHandler.INSERT_CHILDREN_USED)))
                        {
                            parent.getFacets().remove(facetName);
                            children.add(child);
                        }
                        else
                        {
                            UIComponent parentToApply = child;
                            int i = 0;
                            while (parentToApply.getChildCount()-i > 0)
                            {
                                child = parentToApply.getChildren().get(i);
                                if (Boolean.TRUE.equals(child.getAttributes().get(
                                        InsertChildrenHandler.INSERT_CHILDREN_USED)))
                                {
                                    children.add(parentToApply.getChildren().remove(i));
                                }
                                else
                                {
                                    i++;
                                }
                            }
                        }
                    }
                    while (children.size() > 0)
                    {
                        UIComponent child = children.remove(0);
                        if (facetName != null)
                        {
                            ComponentSupport.addFacet(ctx, parent, child, facetName);
                        }
                        else
                        {
                            parent.getChildren().add(child);
                        }
                    }
                }
            }
            return true;
        }
        if (name != null)
        {
            //1. Initialize map used to retrieve facets
            if (_facetHandlers == null || _facetHandlers.isEmpty())
            {
                checkFacetRequired(ctx, name);
                return true;
            }

            initFacetHandlersMap(ctx);

            FaceletHandler handler = _facetHandlersMap.get(name);

            if (handler != null)
            {
                AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
                // Pop the current composite component on stack, so #{cc} references
                // can be resolved correctly, because they are relative to the page
                // that define it.
                FaceletCompositionContext fcc = actx.getFaceletCompositionContext();
                UIComponent innerCompositeComponent = fcc.getCompositeComponentFromStack();
                fcc.popCompositeComponentToStack();
                // Pop the template context, so ui:xx tags and nested composite component
                // cases could work correctly
                TemplateContext itc = actx.popTemplateContext();
                try
                {
                    handler.apply(ctx, parent);
                }
                finally
                {
                    actx.pushTemplateContext(itc);
                    fcc.pushCompositeComponentToStack(innerCompositeComponent);
                }
                return true;
               
            }
            else
            {
                checkFacetRequired(ctx, name);
                return true;
            }
        }
        else
        {
            AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
            // Pop the current composite component on stack, so #{cc} references
            // can be resolved correctly, because they are relative to the page
            // that define it.
            FaceletCompositionContext fcc = actx.getFaceletCompositionContext();
            UIComponent innerCompositeComponent = fcc.getCompositeComponentFromStack();
            fcc.popCompositeComponentToStack();
            // Pop the template context, so ui:xx tags and nested composite component
            // cases could work correctly
            TemplateContext itc = actx.popTemplateContext();
            try
            {
                for (FaceletHandler handler : _componentHandlers)
                {
                    handler.apply(ctx, parent);
                }
            }
            finally
            {
                actx.pushTemplateContext(itc);
                fcc.pushCompositeComponentToStack(innerCompositeComponent);
            }
            return true;
        }
    }
View Full Code Here

Examples of org.apache.myfaces.view.facelets.FaceletCompositionContext

    }
   
    private void checkFacetRequired(FaceletContext ctx, String name)
    {
        AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
        FaceletCompositionContext fcc = actx.getFaceletCompositionContext();
        UIComponent innerCompositeComponent = fcc.getCompositeComponentFromStack();
       
        CompositeComponentBeanInfo beanInfo =
            (CompositeComponentBeanInfo) innerCompositeComponent.getAttributes()
            .get(UIComponent.BEANINFO_KEY);
       
View Full Code Here

Examples of org.apache.myfaces.view.facelets.FaceletCompositionContext

        // our id
        String id = ctx.generateUniqueId(_delegate.getTagId());

        // Cast to use UniqueIdVendor stuff
        FaceletCompositionContext mctx = (FaceletCompositionContext) FaceletCompositionContext.getCurrentInstance(ctx);
               
        // grab our component
        UIComponent c = null;
        //boolean componentFoundInserted = false;

        //Used to preserve the original parent. Note when the view is being refreshed, the real parent could be
        //another component.
        UIComponent oldParent = parent;
       
        if (mctx.isRefreshingSection())
        {
            if (_relocatableResourceHandler != null)
            {
                c = _relocatableResourceHandler.findChildByTagId(ctx, parent, id);
            }
            else
            {
                if (facetName != null)
                {
                    c = ComponentSupport.findChildInFacetByTagId(parent, id, facetName);
                }
                else
                {
                    c = ComponentSupport.findChildInChildrenByTagId(parent, id);
                }
            }
        }
        boolean componentFound = false;
        if (c != null)
        {
            componentFound = true;
            // Check if the binding needs dynamic refresh and if that so, invoke the refresh from this location, to
            // preserve the same context
            if (_delegate.getBinding() != null &&
                c.getAttributes().containsKey(
                    FaceletDynamicComponentRefreshTransientBuildEvent.DYNAMIC_COMPONENT_BINDING_NEEDS_REFRESH))
            {
                VisitContext visitContext = (VisitContext) mctx.getVisitContextFactory().
                    getVisitContext(facesContext, null, VISIT_HINTS_DYN_REFRESH);
                c.visitTree(visitContext, new PublishFaceletDynamicComponentRefreshTransientBuildCallback());
            }
           
            mctx.incrementUniqueComponentId();
           
            // mark all children for cleaning
            if (log.isLoggable(Level.FINE))
            {
                log.fine(_delegate.getTag() + " Component[" + id + "] Found, marking children for cleanup");
            }

            // The call for mctx.markForDeletion(c) is always necessary, because
            // component resource relocation occur as an effect of PostAddToViewEvent,
            // so at this point it is unknown if the component was relocated or not.
            mctx.markForDeletion(c);

            if (_relocatableResourceHandler != null)
            {
                mctx.markRelocatableResourceForDeletion(c);
            }
        }
        else
        {
            c = this.createComponent(ctx);
            if (log.isLoggable(Level.FINE))
            {
                log.fine(_delegate.getTag() + " Component[" + id + "] Created: " + c.getClass().getName());
            }
           
            _delegate.setAttributes(ctx, c);

            // mark it owned by a facelet instance
            c.getAttributes().put(ComponentSupport.MARK_CREATED, id);

            if (facesContext.isProjectStage(ProjectStage.Development))
            {
                c.getAttributes().put(UIComponent.VIEW_LOCATION_KEY,
                        _delegate.getTag().getLocation());
            }

            // assign our unique id
            if (this._id != null)
            {
                mctx.incrementUniqueComponentId();
                c.setId(this._id.getValue(ctx));
            }
            else
            {
                String componentId = mctx.generateUniqueComponentId();
                UniqueIdVendor uniqueIdVendor = mctx.getUniqueIdVendorFromStack();
                if (uniqueIdVendor == null)
                {
                    uniqueIdVendor = facesContext.getViewRoot();
                   
                    if (uniqueIdVendor == null)
                    {
                        // facesContext.getViewRoot() returns null here if we are in
                        // phase restore view, so we have to try to get the view root
                        // via the method in ComponentSupport and our parent
                        uniqueIdVendor = ComponentSupport.getViewRoot(ctx, parent);
                    }
                }
                if (uniqueIdVendor != null)
                {
                    // UIViewRoot implements UniqueIdVendor, so there is no need to cast to UIViewRoot
                    // and call createUniqueId()
                    String uid = uniqueIdVendor.createUniqueId(facesContext, componentId);
                    c.setId(uid);
                }
            }

            if (this._rendererType != null)
            {
                c.setRendererType(this._rendererType);
            }

            // hook method
            _delegate.onComponentCreated(ctx, c, parent);
           
            if (_relocatableResourceHandler != null &&
                _relocatableResourceHandler instanceof ComponentRelocatableResourceHandler)
            {
                UIComponent parentCompositeComponent
                        = mctx.getCompositeComponentFromStack();
                if (parentCompositeComponent != null)
                {
                    c.getAttributes().put(CompositeComponentELUtils.LOCATION_KEY,
                            parentCompositeComponent.getAttributes().get(CompositeComponentELUtils.LOCATION_KEY));
                }
            }
           
            if (mctx.isRefreshingTransientBuild() && _relocatableResourceHandler != null)
            {
                mctx.markRelocatableResourceForDeletion(c);
            }
        }
        c.pushComponentToEL(facesContext, c);

        if (c instanceof UniqueIdVendor)
        {
            mctx.pushUniqueIdVendorToStack((UniqueIdVendor)c);
        }
       
        if (mctx.isDynamicComponentTopLevel())
        {
            mctx.setDynamicComponentTopLevel(false);
            _delegate.applyNextHandler(ctx, c);
            mctx.setDynamicComponentTopLevel(true);
        }
        else
        {
            // first allow c to get populated
            _delegate.applyNextHandler(ctx, c);
        }
       
        boolean oldProcessingEvents = facesContext.isProcessingEvents();
        // finish cleaning up orphaned children
        if (componentFound && !mctx.isDynamicComponentTopLevel())
        {
            mctx.finalizeForDeletion(c);

            //if (!componentFoundInserted)
            //{
                if (mctx.isRefreshingSection())
                {
                    facesContext.setProcessingEvents(false);
                    if (_relocatableResourceHandler != null &&
                        parent != null && !parent.equals(c.getParent()))
                    {
                        // Replace parent with the relocated parent.
                        parent = c.getParent();
                    }
                    ComponentSupport.setCachedFacesContext(c, facesContext);
                }
                if (facetName == null)
                {
                    parent.getChildren().remove(c);
                }
                else
                {
                    ComponentSupport.removeFacet(ctx, parent, c, facetName);
                }
                if (mctx.isRefreshingSection())
                {
                    ComponentSupport.setCachedFacesContext(c, null);
                    facesContext.setProcessingEvents(oldProcessingEvents);
                }
            //}
        }


        if (!componentFound)
        {
            if (c instanceof ClientBehaviorHolder && !UIComponent.isCompositeComponent(c))
            {
                Iterator<AjaxHandler> it = ((AbstractFaceletContext) ctx).getAjaxHandlers();
                if (it != null)
                {
                    while(it.hasNext())
                    {
                        it.next().applyAttachedObject(facesContext, c);
                    }
                }
            }
           
            if (c instanceof EditableValueHolder)
            {
                // add default validators here, because this feature
                // is only available in facelets (see MYFACES-2362 for details)
                addEnclosingAndDefaultValidators(ctx, mctx, facesContext, (EditableValueHolder) c);
            }
        }
       
        _delegate.onComponentPopulated(ctx, c, oldParent);

        if (!mctx.isDynamicComponentTopLevel() || !componentFound)
        {
            if (componentFound && mctx.isRefreshingSection())
            {
                facesContext.setProcessingEvents(false);
                ComponentSupport.setCachedFacesContext(c, facesContext);
            }
            if (facetName == null)
            {
                parent.getChildren().add(c);
            }
            else
            {
                ComponentSupport.addFacet(ctx, parent, c, facetName);
            }
            if (componentFound && mctx.isRefreshingSection())
            {
                ComponentSupport.setCachedFacesContext(c, null);
                facesContext.setProcessingEvents(oldProcessingEvents);
            }
        }

        if (c instanceof UniqueIdVendor)
        {
            mctx.popUniqueIdVendorToStack();
        }

        c.popComponentFromEL(facesContext);
       
        if (mctx.isMarkInitialState())
        {
            //Call it only if we are using partial state saving
            c.markInitialState();
        }
    }
View Full Code Here

Examples of org.apache.myfaces.view.facelets.FaceletCompositionContext

                   
                    if (FaceletViewDeclarationLanguageBase.isDynamicComponentNeedsRefresh(ctx.getFacesContext()))
                    {
                        FaceletViewDeclarationLanguageBase.resetDynamicComponentNeedsRefreshFlag(
                                ctx.getFacesContext());
                        FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(ctx);
                        if (mctx.isUsingPSSOnThisView())
                        {
                            FaceletViewDeclarationLanguage.cleanTransientBuildOnRestore(faces);
                        }
                        else
                        {
View Full Code Here

Examples of org.apache.myfaces.view.facelets.FaceletCompositionContext

        }
        if (! (parent instanceof UIViewRoot) )
        {
            throw new TagException(this.tag, "Parent UIComponent "+parent.getId()+" should be instance of UIViewRoot");
        }
        FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(ctx);
        if (mctx.isBuildingViewMetadata())
        {
            UIComponent metadataFacet = parent.getFacet(UIViewRoot.METADATA_FACET_NAME);
            if (metadataFacet == null)
            {
                metadataFacet = ctx.getFacesContext().getApplication().createComponent(
                        ctx.getFacesContext(), UIPanel.COMPONENT_TYPE, null);
                metadataFacet.setId(UIViewRoot.METADATA_FACET_NAME);
                metadataFacet.getAttributes().put(ComponentSupport.FACET_CREATED_UIPANEL_MARKER, true);
                metadataFacet.getAttributes().put(ComponentSupport.COMPONENT_ADDED_BY_HANDLER_MARKER, Boolean.TRUE);
                parent.getFacets().put(UIViewRoot.METADATA_FACET_NAME, metadataFacet);
            }
        }

        // We have to do nextHandler.apply() in any case, because even if we're not building ViewMetadata
        // we still need to do it so that the mark/delete components can be applied correctly.
        // (The only tag that needs to do something special is f:event, because in this case
        // ComponentHandler.isNew(parent) does not work for UIViewRoot.)
        parent.getAttributes().put(FacetHandler.KEY, UIViewRoot.METADATA_FACET_NAME);
        mctx.startMetadataSection();
        try
        {
            this.nextHandler.apply(ctx, parent);
        }
        finally
        {
            mctx.endMetadataSection();
            parent.getAttributes().remove(FacetHandler.KEY);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.