Package org.apache.myfaces.context

Examples of org.apache.myfaces.context.RequestViewContext


    {
        // 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 we're in production and the list is not yet cached, store it
        if(isProduction && !isCachedList && dependencyList != null)  
        {
            // Note at this point listenerForList cannot be null, but just let dependencyList != null
            // as a sanity check.
            _classToResourceDependencyMap.put(inspectedClass, dependencyList);
        }
       
        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

                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

                    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

       
        // 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

                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

                    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

       
        // 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 && dependencyList != null)
        {
            // Note at this point dependencyList cannot be null, but just let this
            // as a sanity check.
            _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 we're in production and the list is not yet cached, store it
        if(isProduction && !isCachedList && dependencyList != null)  
        {
            // Note at this point listenerForList cannot be null, but just let dependencyList != null
            // as a sanity check.
            _classToResourceDependencyMap.put(inspectedClass, dependencyList);
        }
       
        if (!classAlreadyProcessed)
        {
            rvc.setClassProcessed(inspectedClass);
        }
    }
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.