Package org.apache.myfaces.context

Examples of org.apache.myfaces.context.RequestViewContext


                facesContext.getPartialViewContext().isAjaxRequest() &&
                !facesContext.getAttributes().containsKey(IS_BUILDING_INITIAL_STATE) &&
                MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isStrictJsf2RefreshTargetAjax())
            {
                //!(component.getParent() instanceof ComponentResourceContainer)
                RequestViewContext requestViewContext = RequestViewContext.getCurrentInstance(facesContext);
                requestViewContext.setRenderTarget("head", true);
            }
            facesContext.getViewRoot().addComponentResource(facesContext,
                        component, "head");
        }
    }
View Full Code Here


    {
        // This and only this method handles @ResourceDependency and @ResourceDependencies annotations
        // The source of these annotations is Class<?> inspectedClass.
        // Because Class<?> and its annotations cannot change
        // during request/response, it is sufficient to process Class<?> only once per view.
        RequestViewContext rvc = RequestViewContext.getCurrentInstance(context);
        if (rvc.isClassAlreadyProcessed(inspectedClass))
        {
            return;
        }
        boolean classAlreadyProcessed = false;

       
        List<ResourceDependency> dependencyList = null;
        boolean isCachedList = false;
       
        if(isProduction && _classToResourceDependencyMap.containsKey(inspectedClass))
        {
            dependencyList = _classToResourceDependencyMap.get(inspectedClass);
            if(dependencyList == null)
            {
                return; //class has been inspected and did not contain any resource dependency annotations
            }
           
            isCachedList = true;    // else annotations were found in the cache
        }
       
        if(dependencyList == null//not in production or the class hasn't been inspected yet
        {  
            ResourceDependency dependency = inspectedClass.getAnnotation(ResourceDependency.class);
            ResourceDependencies dependencies = inspectedClass.getAnnotation(ResourceDependencies.class);
            if(dependency != null || dependencies != null)
            {
                //resource dependencies were found using one or both annotations, create and build a new list
                dependencyList = new ArrayList<ResourceDependency>();
               
                if(dependency != null)
                {
                    dependencyList.add(dependency);
                }
               
                if(dependencies != null)
                {
                    dependencyList.addAll(Arrays.asList(dependencies.value()));
                }
            }
        }       
        if (dependencyList != null) //resource dependencies were found through inspection or from cache, handle them
        {
            for (int i = 0, size = dependencyList.size(); i < size; i++)
            {
                ResourceDependency dependency = dependencyList.get(i);
                if (!rvc.isResourceDependencyAlreadyProcessed(dependency))
                {
                    _handleResourceDependency(context, component, dependency);
                    rvc.setResourceDependencyAsProcessed(dependency);
                }
            }
        }
       
        if(isProduction && !isCachedList)   //if we're in production and the list is not yet cached, store it
        {
            //null value stored for dependencyList means no annotations were found
            _classToResourceDependencyMap.put(inspectedClass, dependencyList);
        }
       
        if (!classAlreadyProcessed)
        {
            rvc.setClassProcessed(inspectedClass);
        }
    }
View Full Code Here

                    facesContext.getPartialViewContext().isAjaxRequest() &&
                    !facesContext.getAttributes().containsKey(IS_BUILDING_INITIAL_STATE) &&
                    MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isStrictJsf2RefreshTargetAjax())
                {
                    //!(component.getParent() instanceof ComponentResourceContainer)
                    RequestViewContext requestViewContext = RequestViewContext.getCurrentInstance(facesContext);
                    requestViewContext.setRenderTarget("head", true);
                }

                facesContext.getViewRoot().addComponentResource(facesContext,
                        component, target);
            }
View Full Code Here

                    {
                        List<UIComponent> updatedComponents = null;
                        if (!ExternalContextUtils.isPortlet(_facesContext.getExternalContext()) &&
                                MyfacesConfig.getCurrentInstance(externalContext).isStrictJsf2RefreshTargetAjax())
                        {
                            RequestViewContext rvc = RequestViewContext.getCurrentInstance(_facesContext);
                            if (rvc.isRenderTarget("head"))
                            {
                                UIComponent head = findHeadComponent(viewRoot);
                                if (head != null)
                                {
                                    writer.startUpdate("javax.faces.ViewHead");
                                    head.encodeAll(_facesContext);
                                    writer.endUpdate();
                                    if (updatedComponents == null)
                                    {
                                        updatedComponents = new ArrayList<UIComponent>();
                                    }
                                    updatedComponents.add(head);
                                }
                            }
                            if (rvc.isRenderTarget("body") || rvc.isRenderTarget("form"))
                            {
                                UIComponent body = findBodyComponent(viewRoot);
                                if (body != null)
                                {
                                    writer.startUpdate("javax.faces.ViewBody");
                                    body.encodeAll(_facesContext);
                                    writer.endUpdate();
                                    if (updatedComponents == null)
                                    {
                                        updatedComponents = new ArrayList<UIComponent>();
                                    }
                                    updatedComponents.add(body);
                                }
                            }
                        }

                        VisitContext visitCtx = VisitContext.createVisitContext(_facesContext, renderIds, hints);
                        viewRoot.visitTree(visitCtx,
                                           new PhaseAwareVisitCallback(_facesContext, phaseId, updatedComponents));
                    }
                }
                else if (!ExternalContextUtils.isPortlet(_facesContext.getExternalContext()) &&
                        MyfacesConfig.getCurrentInstance(externalContext).isStrictJsf2RefreshTargetAjax())
                {
                    RequestViewContext rvc = RequestViewContext.getCurrentInstance(_facesContext);
                    if (rvc.isRenderTarget("head"))
                    {
                        UIComponent head = findHeadComponent(viewRoot);
                        if (head != null)
                        {
                            writer.startUpdate("javax.faces.ViewHead");
                            head.encodeAll(_facesContext);
                            writer.endUpdate();
                        }
                    }
                    if (rvc.isRenderTarget("body") || rvc.isRenderTarget("form"))
                    {
                        UIComponent body = findBodyComponent(viewRoot);
                        if (body != null)
                        {
                            writer.startUpdate("javax.faces.ViewBody");
View Full Code Here

    private void _handleResourceDependencyAnnotations(FacesContext context, Class<?> inspectedClass, UIComponent component, boolean isProduction)
    {
        // This and only this method handles @ResourceDependency and @ResourceDependencies annotations
        // The source of these annotations is Class<?> inspectedClass. Because Class<?> and its annotations cannot change
        // during request/response, it is sufficient to process Class<?> only once per view.
        RequestViewContext rvc = RequestViewContext.getCurrentInstance(context);
        if (rvc.isClassAlreadyProcessed(inspectedClass))
        {
            return;
        }
        boolean classAlreadyProcessed = false;

       
        List<ResourceDependency> dependencyList = null;
        boolean isCachedList = false;
       
        if(isProduction && _classToResourceDependencyMap.containsKey(inspectedClass))
        {
            dependencyList = _classToResourceDependencyMap.get(inspectedClass);
            if(dependencyList == null)
                return; //class has been inspected and did not contain any resource dependency annotations
           
            isCachedList = true;    // else annotations were found in the cache
        }
       
        if(dependencyList == null//not in production or the class hasn't been inspected yet
        {  
            ResourceDependency dependency = inspectedClass.getAnnotation(ResourceDependency.class);
            ResourceDependencies dependencies = inspectedClass.getAnnotation(ResourceDependencies.class);
            if(dependency != null || dependencies != null)
            {
                //resource dependencies were found using one or both annotations, create and build a new list
                dependencyList = new ArrayList<ResourceDependency>();
               
                if(dependency != null)
                    dependencyList.add(dependency);
               
                if(dependencies != null)
                    dependencyList.addAll(Arrays.asList(dependencies.value()));
            }
        }       
        if (dependencyList != null) //resource dependencies were found through inspection or from cache, handle them
        {
            for (int i = 0, size = dependencyList.size(); i < size; i++)
            {
                ResourceDependency dependency = dependencyList.get(i);
                if (!rvc.isResourceDependencyAlreadyProcessed(dependency))
                {
                    _handleResourceDependency(context, component, dependency);
                    rvc.setResourceDependencyAsProcessed(dependency);
                }
            }
        }
       
        if(isProduction && !isCachedList)   //if we're in production and the list is not yet cached, store it
            _classToResourceDependencyMap.put(inspectedClass, dependencyList)//null value stored for dependencyList means no annotations were found
       
        if (!classAlreadyProcessed) {
            rvc.setClassProcessed(inspectedClass);
        }
    }
View Full Code Here

                if (isPostAddToViewEventAfterBuildInitialState &&
                        MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).
                            isStrictJsf2RefreshTargetAjax())
                {
                    //!(component.getParent() instanceof ComponentResourceContainer)
                    RequestViewContext requestViewContext = RequestViewContext.getCurrentInstance(facesContext);
                    requestViewContext.setRenderTarget("head", true);
                }
            }
            facesContext.getViewRoot().addComponentResource(facesContext,
                        component, "head");
        }
View Full Code Here

       
        // This and only this method handles @ResourceDependency and @ResourceDependencies annotations
        // The source of these annotations is Class<?> inspectedClass.
        // Because Class<?> and its annotations cannot change
        // during request/response, it is sufficient to process Class<?> only once per view.
        RequestViewContext rvc = RequestViewContext.getCurrentInstance(context);
        Class<?> inspectedClass = inspected.getClass();
        if (rvc.isClassAlreadyProcessed(inspectedClass))
        {
            return;
        }
        boolean classAlreadyProcessed = false;

       
        List<ResourceDependency> dependencyList = null;
        boolean isCachedList = false;
       
        if(context.isProjectStage(ProjectStage.Production) && _classToResourceDependencyMap.containsKey(inspectedClass))
        {
            dependencyList = _classToResourceDependencyMap.get(inspectedClass);
            if(dependencyList == null)
            {
                return; //class has been inspected and did not contain any resource dependency annotations
            }
            else if (dependencyList.isEmpty())
            {
                return;
            }
           
            isCachedList = true;    // else annotations were found in the cache
        }
       
        if(dependencyList == null//not in production or the class hasn't been inspected yet
        {  
            ResourceDependency dependency = inspectedClass.getAnnotation(ResourceDependency.class);
            ResourceDependencies dependencies = inspectedClass.getAnnotation(ResourceDependencies.class);
            if(dependency != null || dependencies != null)
            {
                //resource dependencies were found using one or both annotations, create and build a new list
                dependencyList = new ArrayList<ResourceDependency>();
               
                if(dependency != null)
                {
                    dependencyList.add(dependency);
                }
               
                if(dependencies != null)
                {
                    dependencyList.addAll(Arrays.asList(dependencies.value()));
                }
            }
            else
            {
                dependencyList = Collections.emptyList();
            }
        }

        //resource dependencies were found through inspection or from cache, handle them
        if (dependencyList != null && !dependencyList.isEmpty())
        {
            for (int i = 0, size = dependencyList.size(); i < size; i++)
            {
                ResourceDependency dependency = dependencyList.get(i);
                if (!rvc.isResourceDependencyAlreadyProcessed(dependency))
                {
                    _handleAttachedResourceDependency(context, dependency, inspectedClass);
                    rvc.setResourceDependencyAsProcessed(dependency);
                }
            }
        }
       
        //if we're in production and the list is not yet cached, store it
        if(context.isProjectStage(ProjectStage.Production) && !isCachedList)  
        {
            // Note at this point listenerForList cannot be null, but just let this
            // as a sanity check.
            if (dependencyList != null)
            {
                _classToResourceDependencyMap.put(inspectedClass, dependencyList);
            }
        }
       
        if (!classAlreadyProcessed)
        {
            rvc.setClassProcessed(inspectedClass);
        }
    }
View Full Code Here

    {
        // This and only this method handles @ResourceDependency and @ResourceDependencies annotations
        // The source of these annotations is Class<?> inspectedClass.
        // Because Class<?> and its annotations cannot change
        // during request/response, it is sufficient to process Class<?> only once per view.
        RequestViewContext rvc = RequestViewContext.getCurrentInstance(context);
        if (rvc.isClassAlreadyProcessed(inspectedClass))
        {
            return;
        }
        boolean classAlreadyProcessed = false;

       
        List<ResourceDependency> dependencyList = null;
        boolean isCachedList = false;
       
        if(isProduction && _classToResourceDependencyMap.containsKey(inspectedClass))
        {
            dependencyList = _classToResourceDependencyMap.get(inspectedClass);
            if(dependencyList == null)
            {
                return; //class has been inspected and did not contain any resource dependency annotations
            }
            else if (dependencyList.isEmpty())
            {
                return;
            }
           
            isCachedList = true;    // else annotations were found in the cache
        }
       
        if(dependencyList == null//not in production or the class hasn't been inspected yet
        {  
            ResourceDependency dependency = inspectedClass.getAnnotation(ResourceDependency.class);
            ResourceDependencies dependencies = inspectedClass.getAnnotation(ResourceDependencies.class);
            if(dependency != null || dependencies != null)
            {
                //resource dependencies were found using one or both annotations, create and build a new list
                dependencyList = new ArrayList<ResourceDependency>();
               
                if(dependency != null)
                {
                    dependencyList.add(dependency);
                }
               
                if(dependencies != null)
                {
                    dependencyList.addAll(Arrays.asList(dependencies.value()));
                }
            }
            else
            {
                dependencyList = Collections.emptyList();
            }
        }       
        // resource dependencies were found through inspection or from cache, handle them
        if (dependencyList != null && !dependencyList.isEmpty())
        {
            for (int i = 0, size = dependencyList.size(); i < size; i++)
            {
                ResourceDependency dependency = dependencyList.get(i);
                if (!rvc.isResourceDependencyAlreadyProcessed(dependency))
                {
                    _handleResourceDependency(context, component, dependency, inspectedClass);
                    rvc.setResourceDependencyAsProcessed(dependency);
                }
            }
        }
       
        if(isProduction && !isCachedList)   //if we're in production and the list is not yet cached, store it
        {
            // Note at this point listenerForList cannot be null, but just let this
            // as a sanity check.
            if (dependencyList != null)
            {
                _classToResourceDependencyMap.put(inspectedClass, dependencyList);
            }
        }
       
        if (!classAlreadyProcessed)
        {
            rvc.setClassProcessed(inspectedClass);
        }
    }
View Full Code Here

    private void _handleResourceDependencyAnnotations(FacesContext context, Class<?> inspectedClass, UIComponent component, boolean isProduction)
    {
        // This and only this method handles @ResourceDependency and @ResourceDependencies annotations
        // The source of these annotations is Class<?> inspectedClass. Because Class<?> and its annotations cannot change
        // during request/response, it is sufficient to process Class<?> only once per view.
        RequestViewContext rvc = RequestViewContext.getCurrentInstance(context);
        if (rvc.isClassAlreadyProcessed(inspectedClass))
        {
            return;
        }
        boolean classAlreadyProcessed = false;

       
        List<ResourceDependency> dependencyList = null;
        boolean isCachedList = false;
       
        if(isProduction && _classToResourceDependencyMap.containsKey(inspectedClass))
        {
            dependencyList = _classToResourceDependencyMap.get(inspectedClass);
            if(dependencyList == null)
                return; //class has been inspected and did not contain any resource dependency annotations
           
            isCachedList = true;    // else annotations were found in the cache
        }
       
        if(dependencyList == null//not in production or the class hasn't been inspected yet
        {  
            ResourceDependency dependency = inspectedClass.getAnnotation(ResourceDependency.class);
            ResourceDependencies dependencies = inspectedClass.getAnnotation(ResourceDependencies.class);
            if(dependency != null || dependencies != null)
            {
                //resource dependencies were found using one or both annotations, create and build a new list
                dependencyList = new ArrayList<ResourceDependency>();
               
                if(dependency != null)
                    dependencyList.add(dependency);
               
                if(dependencies != null)
                    dependencyList.addAll(Arrays.asList(dependencies.value()));
            }
        }       
        if (dependencyList != null) //resource dependencies were found through inspection or from cache, handle them
        {
            for (ResourceDependency dependency : dependencyList)
            {
                if (!rvc.isResourceDependencyAlreadyProcessed(dependency))
                {
                    _handleResourceDependency(context, component, dependency);
                    rvc.setResourceDependencyAsProcessed(dependency);
                }
            }
        }
       
        if(isProduction && !isCachedList)   //if we're in production and the list is not yet cached, store it
            _classToResourceDependencyMap.put(inspectedClass, dependencyList)//null value stored for dependencyList means no annotations were found
       
        if (!classAlreadyProcessed) {
            rvc.setClassProcessed(inspectedClass);
        }
    }
View Full Code Here

                    if (isPostAddToViewEventAfterBuildInitialState &&                   
                        MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).
                            isStrictJsf2RefreshTargetAjax())
                    {
                        //!(component.getParent() instanceof ComponentResourceContainer)
                        RequestViewContext requestViewContext = RequestViewContext.getCurrentInstance(facesContext);
                        requestViewContext.setRenderTarget("head", true);
                    }
                }

                facesContext.getViewRoot().addComponentResource(facesContext,
                        component, target);
View Full Code Here

TOP

Related Classes of org.apache.myfaces.context.RequestViewContext

Copyright © 2018 www.massapicom. 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.