Examples of AbstractFaceletContext


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

     *        javax.faces.component.UIComponent)
     */
    public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
            ELException
    {
        AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
        // eval include
        try
        {
            String[] names = null;
            ValueExpression[] values = null;
            if (this._vars.length > 0)
            {
                names = new String[_vars.length];
                values = new ValueExpression[_vars.length];
                for (int i = 0; i < _vars.length; i++)
                {
                    names[i] = _vars[i].getLocalName();
                    values[i] = _vars[i].getValueExpression(ctx, Object.class);
                }
            }
            actx.pushTemplateContext(new TemplateContextImpl());
            if (this._vars.length > 0)
            {
                for (int i = 0; i < this._vars.length; i++)
                {
                    ((AbstractFaceletContext) ctx).getTemplateContext().setParameter(names[i], values[i]);
                }
            }
            //Disable caching always, even in 'always' mode
            actx.getTemplateContext().setAllowCacheELExpressions(false);
            actx.pushClient(this);
            ctx.includeFacelet(parent, this._location);
        }
        catch (FileNotFoundException e)
        {
            throw new TagException(this.tag, e.getMessage());
        }
        finally
        {

            // make sure we undo our changes
            actx.popClient(this);
            actx.popTemplateContext();
            //ctx.setVariableMapper(orig);
        }
    }
View Full Code Here

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

                return false;
            }
            DefineHandler handler = (DefineHandler) this._handlers.get(name);
            if (handler != null)
            {
                AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
                TemplateContext itc = actx.popTemplateContext();
                try
                {
                    handler.applyDefinition(ctx, parent);
                }
                finally
                {
                    actx.pushTemplateContext(itc);
                }
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
            TemplateContext itc = actx.popTemplateContext();
            try
            {
                this.nextHandler.apply(ctx, parent);
            }
            finally
            {
                actx.pushTemplateContext(itc);
            }
            return true;
        }
    }
View Full Code Here

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

     * @see javax.faces.view.facelets.FaceletHandler#apply(javax.faces.view.facelets.FaceletContext, javax.faces.component.UIComponent)
     */
    public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
            ELException
    {
        AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
        FaceletCompositionContext fcc = FaceletCompositionContext.getCurrentInstance(ctx);
        String path;
        if (!src.isLiteral())
        {
            String uniqueId = fcc.startComponentUniqueIdSection();
            path = getSrcValue(actx, fcc, parent, uniqueId);
            ComponentSupport.saveInitialTagState(ctx, fcc, parent, uniqueId, path);
        }
        else
        {
            path = this.src.getValue(ctx);
        }
        try
        {
            if (path == null || path.length() == 0)
            {
                return;
            }
            VariableMapper orig = ctx.getVariableMapper();
            ctx.setVariableMapper(new VariableMapperWrapper(orig));
            try
            {
                //Only ui:param could be inside ui:include.
                //this.nextHandler.apply(ctx, null);
               
                URL url = null;
                // if we are in ProjectStage Development and the path equals "javax.faces.error.xhtml"
                // we should include the default error page
                if (ctx.getFacesContext().isProjectStage(ProjectStage.Development)
                        && ERROR_PAGE_INCLUDE_PATH.equals(path))
                {
                    url =ClassUtils.getResource(ERROR_FACELET);
                   
                }
                try
                {
                    if (_params != null)
                    {
                        // ui:include defines a new TemplateContext, but ui:param EL expressions
                        // defined inside should be built before the new context is setup, to
                        // apply then after. The final effect is EL expressions will be resolved
                        // correctly when nested ui:params with the same name or based on other
                        // ui:params are used.
                       
                        String[] names = new String[_params.length];
                        ValueExpression[] values = new ValueExpression[_params.length];
                       
                        for (int i = 0; i < _params.length; i++)
                        {
                            names[i] = _params[i].getName(ctx);
                            values[i] = _params[i].getValue(ctx);
                        }
                       
                        actx.pushTemplateContext(new TemplateContextImpl());
                       
                        for (int i = 0; i < _params.length; i++)
                        {
                            _params[i].apply(ctx, parent, names[i], values[i]);
                        }
                    }
                    else
                    {
                        actx.pushTemplateContext(new TemplateContextImpl());
                    }
                    if (url == null)
                    {
                        ctx.includeFacelet(parent, path);
                    }
                    else
                    {
                        ctx.includeFacelet(parent, url);
                    }
                }
                finally
                {
                    actx.popTemplateContext();
                }
            }
            finally
            {
                ctx.setVariableMapper(orig);
View Full Code Here

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

        //    {
        //        _params[i].apply(ctx, parent);
        //    }
        //}

        AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
        actx.pushClient(this);

        if (_params != null)
        {
            //VariableMapper vm = new VariableMapperWrapper(orig);
            //ctx.setVariableMapper(vm);
            for (int i = 0; i < _params.length; i++)
            {
                _params[i].apply(ctx, parent);
            }
        }

        FaceletCompositionContext fcc = FaceletCompositionContext.getCurrentInstance(ctx);
        String path;
        if (!_template.isLiteral())
        {
            String uniqueId = fcc.startComponentUniqueIdSection();
            path = getTemplateValue(actx, fcc, parent, uniqueId);
            ComponentSupport.saveInitialTagState(ctx, fcc, parent, uniqueId, path);
        }
        else
        {
            path = _template.getValue(ctx);
        }
        try
        {
            ctx.includeFacelet(parent, path);
        }
        finally
        {
            //ctx.setVariableMapper(orig);
            actx.popClient(this);
        }
        if (!_template.isLiteral())
        {
            fcc.endComponentUniqueIdSection();
        }
View Full Code Here

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

   
    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(UIPanel.COMPONENT_TYPE);
            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(),null);
                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();
        try
        {
            faceletContext.setVariableMapper(new VariableMapperWrapper(orig));
            actx.pushCompositeComponentClient(this);
            Resource resourceForCurrentView = faceletContext.getFacesContext().getApplication().
                getResourceHandler().createResource(_resource.getResourceName(), _resource.getLibraryName());
            if (resourceForCurrentView != null)
            {
                //Wrap it for serialization.
                resourceForCurrentView = new CompositeResouceWrapper(resourceForCurrentView);
            }
            else
            {
                //If a resource cannot be resolved it means a default for the current
                //composite component does not exists.
                throw new TagException(getTag(), "Composite Component " + getTag().getQName()
                        + " requires a default instance that can be found by the installed ResourceHandler.");
            }
            actx.applyCompositeComponent(compositeFacetPanel, resourceForCurrentView);
        }
        finally
        {
            actx.popCompositeComponentClient();
            faceletContext.setVariableMapper(orig);
        }
    }
View Full Code Here

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

            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, parent, 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.AbstractFaceletContext

        }
    }
   
    private void checkFacetRequired(FaceletContext ctx, UIComponent parent, 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.AbstractFaceletContext

     * @see javax.faces.view.facelets.FaceletHandler#apply(javax.faces.view.facelets.FaceletContext, javax.faces.component.UIComponent)
     */
    public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
            ELException
    {
        AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
        actx.extendClient(this);
        boolean found = false;
        try
        {
            found = actx.includeDefinition(parent, this.name);
        }
        finally
        {
            actx.popExtendedClient(this);
        }
        if (!found)
        {
            this.nextHandler.apply(ctx, parent);
        }
View Full Code Here

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

            throws IOException
    {
        UIComponent parentCompositeComponent
                = FaceletCompositionContext.getCurrentInstance(ctx).getCompositeComponentFromStack();
       
        AbstractFaceletContext actx = (AbstractFaceletContext) ctx;

        if (actx.isBuildingCompositeComponentMetadata())
        {
            CompositeComponentBeanInfo beanInfo =
                (CompositeComponentBeanInfo) parentCompositeComponent.getAttributes()
                .get(UIComponent.BEANINFO_KEY);
           
            if (beanInfo == null)
            {
                if (log.isLoggable(Level.SEVERE))
                {
                    log.severe("Cannot find composite bean descriptor UIComponent.BEANINFO_KEY ");
                }
                return;
            }
           
            beanInfo.getBeanDescriptor().setValue(INSERT_CHILDREN_USED, Boolean.TRUE);
        }
        else
        {
            actx.includeCompositeComponentDefinition(parent, null);
        }
    }
View Full Code Here

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

            return false;
        }

        public ELText apply(ExpressionFactory factory, ELContext ctx)
        {
            AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
           
            if (actx.isAllowCacheELExpressions() && cached != null)
            {
                // In TagAttributeImpl.getValueExpression(), it is necessary to do an
                // special logic to detect the cases where #{cc} is included into the
                // EL expression and set the proper ccLevel. In this case, it is usual
                // the parent composite component is always on top, but it is possible to
                // write a nesting case with <composite:insertChildren>, and
                // pass a flat EL expression over itself. So, it is necessary to update
                // the ccLevel to make possible to find the right parent where this
                // expression belongs to.
                if ((this.capabilities & EL_CC) != 0)
                {
                    return new ELTextVariable(((LocationValueExpression)cached.ve).apply(
                            actx.getFaceletCompositionContext().getCompositeComponentLevel()));
                }
                return cached;
            }
           
            actx.beforeConstructELExpression();
            try
            {
                ValueExpression valueExpression
                        = factory.createValueExpression(ctx, this.ve.getExpressionString(), String.class);
             
                if ((this.capabilities & EL_CC) != 0)
                {
                    UIComponent cc = actx.getFaceletCompositionContext().getCompositeComponentFromStack();
                    if (cc != null)
                    {
                        Location location = (Location) cc.getAttributes().get(CompositeComponentELUtils.LOCATION_KEY);
                        if (location != null)
                        {
                            if (ExternalSpecifications.isUnifiedELAvailable())
                            {
                                valueExpression = new LocationValueExpressionUEL(location, valueExpression,
                                        actx.getFaceletCompositionContext().getCompositeComponentLevel());
                            }
                            else
                            {
                                valueExpression = new LocationValueExpression(location, valueExpression,
                                        actx.getFaceletCompositionContext().getCompositeComponentLevel());
                            }
                        }
                    }
                }
                else if ((this.capabilities & EL_RESOURCE) != 0)
                {
                    UIComponent cc = actx.getFaceletCompositionContext().getCompositeComponentFromStack();
                    if (cc != null)
                    {
                        Location location = (Location) cc.getAttributes().get(CompositeComponentELUtils.LOCATION_KEY);
                        if (location != null)
                        {
                            if (ExternalSpecifications.isUnifiedELAvailable())
                            {
                                valueExpression = new ResourceLocationValueExpressionUEL(location, valueExpression);
                            }
                            else
                            {
                                valueExpression = new ResourceLocationValueExpression(location, valueExpression);
                            }
                        }
                    }
                }
               
                ELTextVariable eltv = new ELTextVariable(valueExpression);
               
                if (actx.isAllowCacheELExpressions() && !actx.isAnyFaceletsVariableResolved())
                {
                     cached = eltv;
                }
                return eltv;
            }
            finally
            {
                actx.afterConstructELExpression();
            }
        }
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.