Package org.apache.myfaces.view.facelets

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


            }

        }
       
        UIViewRoot root = facesContext.getViewRoot();
        ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
        ViewPool pool = (processor != null) ? processor.getViewPool(facesContext, root) : null;
        if (pool != null && pool.isDeferredNavigationEnabled() &&
            processor.isViewPoolStrategyAllowedForThisView(facesContext, root) &&
            (PhaseId.INVOKE_APPLICATION.equals(facesContext.getCurrentPhaseId()) ||
             PhaseId.APPLY_REQUEST_VALUES.equals(facesContext.getCurrentPhaseId())) )
        {
            NavigationHandler navigationHandler = application.getNavigationHandler();
            if (navigationHandler instanceof ConfigurableNavigationHandler)
View Full Code Here


        {
            throw new ViewNotFoundException("A view is required to execute "+facesContext.getCurrentPhaseId());
        }
        facesContext.getViewRoot().processDecodes(facesContext);
       
        ViewPoolProcessor processor = getViewPoolProcessor(facesContext);
        if (processor != null)
        {
            processor.processDeferredNavigation(facesContext);
        }
        return false;
    }
View Full Code Here

        {
            throw new ViewNotFoundException("A view is required to execute "+facesContext.getCurrentPhaseId());
        }
        facesContext.getViewRoot().processApplication(facesContext);
       
        ViewPoolProcessor processor = getViewPoolProcessor(facesContext);
        if (processor != null)
        {
            processor.processDeferredNavigation(facesContext);
        }
       
        return false;
    }
View Full Code Here

                {
                    partialViewContext.setRenderAll(true);
                }

                // Dispose view if the view has been marked as disposable by default action listener
                ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
                if (processor != null &&
                    processor.isViewPoolEnabledForThisView(facesContext, facesContext.getViewRoot()))
                {
                    processor.disposeView(facesContext, facesContext.getViewRoot());
                }
               
                // JSF 2.0 Spec call Flash.setRedirect(true) to notify Flash scope and take proper actions
                externalContext.getFlash().setRedirect(true);
                try
                {
                    externalContext.redirect(redirectPath);
                    facesContext.responseComplete();
                }
                catch (IOException e)
                {
                    throw new FacesException(e.getMessage(), e);
                }
            }
            else
            {
                ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
                //create new view
                String newViewId = navigationCase.getToViewId(facesContext);

                // JSF 2.0 the javadoc of handleNavigation() says something like this
                // "...If the view has changed after an application action, call
                // PartialViewContext.setRenderAll(true)...". The effect is that ajax requests
                // are included on navigation.
                PartialViewContext partialViewContext = facesContext.getPartialViewContext();
                String viewId = facesContext.getViewRoot() != null ? facesContext.getViewRoot().getViewId() : null;
                if ( partialViewContext.isPartialRequest() &&
                     !partialViewContext.isRenderAll() &&
                     newViewId != null &&
                     !newViewId.equals(viewId))
                {
                    partialViewContext.setRenderAll(true);
                }

                if (facesContext.getViewRoot() != null &&
                    facesContext.getViewRoot().getAttributes().containsKey("oam.CALL_PRE_DISPOSE_VIEW"))
                {
                    facesContext.getAttributes().put(SKIP_ITERATION_HINT, Boolean.TRUE);
                    facesContext.getViewRoot().visitTree(VisitContext.createVisitContext(facesContext),
                                                         new PreDisposeViewCallback());
                    facesContext.getAttributes().remove(SKIP_ITERATION_HINT);
                }
               
                applyFlowTransition(facesContext, navigationContext);

                // Dispose view if the view has been marked as disposable by default action listener
                ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
                if (processor != null &&
                    processor.isViewPoolEnabledForThisView(facesContext, facesContext.getViewRoot()))
                {
                    processor.disposeView(facesContext, facesContext.getViewRoot());
                }
               
                // create UIViewRoot for new view
                UIViewRoot viewRoot = null;
               
View Full Code Here

            }

        }
       
        UIViewRoot root = facesContext.getViewRoot();
        ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
        ViewPool pool = (processor != null) ? processor.getViewPool(facesContext, root) : null;
        if (pool != null && pool.isDeferredNavigationEnabled() &&
            processor.isViewPoolStrategyAllowedForThisView(facesContext, root) &&
            (PhaseId.INVOKE_APPLICATION.equals(facesContext.getCurrentPhaseId()) ||
             PhaseId.APPLY_REQUEST_VALUES.equals(facesContext.getCurrentPhaseId())) )
        {
            NavigationHandler navigationHandler = application.getNavigationHandler();
            if (navigationHandler instanceof ConfigurableNavigationHandler)
View Full Code Here

        {
            throw new ViewNotFoundException("A view is required to execute "+facesContext.getCurrentPhaseId());
        }
        facesContext.getViewRoot().processDecodes(facesContext);
       
        ViewPoolProcessor processor = getViewPoolProcessor(facesContext);
        if (processor != null)
        {
            processor.processDeferredNavigation(facesContext);
        }
        return false;
    }
View Full Code Here

        {
            throw new ViewNotFoundException("A view is required to execute "+facesContext.getCurrentPhaseId());
        }
        facesContext.getViewRoot().processApplication(facesContext);
       
        ViewPoolProcessor processor = getViewPoolProcessor(facesContext);
        if (processor != null)
        {
            processor.processDeferredNavigation(facesContext);
        }
       
        return false;
    }
View Full Code Here

                {
                    partialViewContext.setRenderAll(true);
                }

                // Dispose view if the view has been marked as disposable by default action listener
                ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
                if (processor != null &&
                    processor.isViewPoolEnabledForThisView(facesContext, facesContext.getViewRoot()))
                {
                    processor.disposeView(facesContext, facesContext.getViewRoot());
                }
               
                // JSF 2.0 Spec call Flash.setRedirect(true) to notify Flash scope and take proper actions
                externalContext.getFlash().setRedirect(true);
                try
                {
                    externalContext.redirect(redirectPath);
                    facesContext.responseComplete();
                }
                catch (IOException e)
                {
                    throw new FacesException(e.getMessage(), e);
                }
            }
            else
            {
                ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
                //create new view
                String newViewId = navigationCase.getToViewId(facesContext);

                // JSF 2.0 the javadoc of handleNavigation() says something like this
                // "...If the view has changed after an application action, call
                // PartialViewContext.setRenderAll(true)...". The effect is that ajax requests
                // are included on navigation.
                PartialViewContext partialViewContext = facesContext.getPartialViewContext();
                String viewId = facesContext.getViewRoot() != null ? facesContext.getViewRoot().getViewId() : null;
                if ( partialViewContext.isPartialRequest() &&
                     !partialViewContext.isRenderAll() &&
                     newViewId != null &&
                     !newViewId.equals(viewId))
                {
                    partialViewContext.setRenderAll(true);
                }

                if (facesContext.getViewRoot() != null &&
                    facesContext.getViewRoot().getAttributes().containsKey("oam.CALL_PRE_DISPOSE_VIEW"))
                {
                    facesContext.getAttributes().put(SKIP_ITERATION_HINT, Boolean.TRUE);
                    facesContext.getViewRoot().visitTree(VisitContext.createVisitContext(facesContext),
                                                         new PreDisposeViewCallback());
                    facesContext.getAttributes().remove(SKIP_ITERATION_HINT);
                }
               
                applyFlowTransition(facesContext, navigationContext);

                // Dispose view if the view has been marked as disposable by default action listener
                ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
                if (processor != null &&
                    processor.isViewPoolEnabledForThisView(facesContext, facesContext.getViewRoot()))
                {
                    processor.disposeView(facesContext, facesContext.getViewRoot());
                }
               
                // create UIViewRoot for new view
                UIViewRoot viewRoot = null;
               
View Full Code Here

     */
    @Test
    public void testDynPageResourceCleanup1() throws Exception
    {
        facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE);
        ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
       
        // Store structure for state checkA=false
        facesContext.getExternalContext().getRequestMap().put("checkA", Boolean.FALSE);
        UIViewRoot root = facesContext.getViewRoot();
        vdl.buildView(facesContext, root, "dynPageResourceCleanup1.xhtml");
        processor.storeViewStructureMetadata(facesContext, root);

        // Store structure for state checkA=true
        facesContext.getExternalContext().getRequestMap().put("checkA", Boolean.TRUE);
        root = new UIViewRoot();
        root.setViewId("/test");
        root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
        facesContext.setViewRoot(root);
        vdl.buildView(facesContext, root, "dynPageResourceCleanup1.xhtml");
       
        processor.storeViewStructureMetadata(facesContext, root);
       
        // Try change a view with state checkA=true to checkA=false
        facesContext.getAttributes().remove(root); //change set filled view
        facesContext.getExternalContext().getRequestMap().put("checkA", Boolean.FALSE);
        vdl.buildView(facesContext, root, "dynPageResourceCleanup1.xhtml");
       
        UIComponent headerFacet = root.getFacet("head");
        int oldCount = headerFacet.getChildCount();
        // the resource should still be there
        //Assert.assertEquals(1, oldCount);
        // The code in MYFACES-3659 reset the component after refresh
        Assert.assertEquals(0, oldCount);

        // Clear the view and synchronize resources
        ViewStructureMetadata metadata = processor.retrieveViewStructureMetadata(facesContext, root);
        Assert.assertNotNull(metadata);
        processor.clearTransientAndNonFaceletComponentsForDynamicView(facesContext, root, metadata);
       
        // the resource added by state checkA=true should not be there
        Assert.assertEquals(0, headerFacet.getChildCount());
    }
View Full Code Here

     */
    @Test
    public void testDynPageResourceCleanup2() throws Exception
    {
        facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE);
        ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
       
        // Store structure for state checkA=false
        facesContext.getExternalContext().getRequestMap().put("checkA", Boolean.FALSE);
        UIViewRoot root = facesContext.getViewRoot();
        vdl.buildView(facesContext, root, "dynPageResourceCleanup2.xhtml");
        processor.storeViewStructureMetadata(facesContext, root);

        // Store structure for state checkA=true
        facesContext.getExternalContext().getRequestMap().put("checkA", Boolean.TRUE);
        root = new UIViewRoot();
        root.setViewId("/test");
        root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
        facesContext.setViewRoot(root);
        vdl.buildView(facesContext, root, "dynPageResourceCleanup2.xhtml");
       
        processor.storeViewStructureMetadata(facesContext, root);
       
        // Try change a view with state checkA=true to checkA=false
        facesContext.getAttributes().remove(root); //change set filled view
        facesContext.getExternalContext().getRequestMap().put("checkA", Boolean.FALSE);
        vdl.buildView(facesContext, root, "dynPageResourceCleanup2.xhtml");
       
        // the resource should still be there
        UIComponent headerFacet = root.getFacet("head");
        int oldCount = headerFacet.getChildCount();
        Assert.assertEquals(1, oldCount);

        // Clear the view and synchronize resources
        ViewStructureMetadata metadata = processor.retrieveViewStructureMetadata(facesContext, root);
        Assert.assertNotNull(metadata);
        processor.clearTransientAndNonFaceletComponentsForDynamicView(facesContext, root, metadata);
       
        // the resource added by state checkA=true should not be there
        Assert.assertEquals(0, headerFacet.getChildCount());
    }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.view.facelets.ViewPoolProcessor

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.