Package org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi

Examples of org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.ViewConfigEntry


    public void testSimpleInterfaceBasedConfigs()
    {
        viewConfigExtension.addPageDefinition(SimpleInterfaceBasedConfigs.Wizards.Registration.Step1.class);
        viewConfigExtension.addPageDefinition(SimpleInterfaceBasedConfigs.Wizards.Order.Step1.class);

        ViewConfigEntry registrationConfigEntry = ViewConfigCache.getViewDefinition(SimpleInterfaceBasedConfigs.Wizards.Registration.Step1.class);
        ViewConfigEntry orderConfigEntry = ViewConfigCache.getViewDefinition(SimpleInterfaceBasedConfigs.Wizards.Order.Step1.class);

        assertEquals(registrationConfigEntry.getViewId(),
                "/pages/wizards/registration/step1.xhtml");
        assertEquals(orderConfigEntry.getViewId(),
                "/pages/wizards/order/step1.xhtml");

        assertEquals(registrationConfigEntry.getNavigationMode(), Page.NavigationMode.DEFAULT);
        assertEquals(orderConfigEntry.getNavigationMode(), Page.NavigationMode.REDIRECT);

        assertTrue(registrationConfigEntry.getAccessDecisionVoters().size() == 0);
        assertEquals(orderConfigEntry.getAccessDecisionVoters().size(), 1);
        assertEquals(orderConfigEntry.getAccessDecisionVoters().iterator().next(), TestAccessDecisionVoter1.class);
    }
View Full Code Here


        assertEquals(ViewConfigCache.getViewDefinition(NavigationOverriding1.RedirectedPage1.class).getViewId(),
                                                       "/redirectedPage1.xhtml");
        assertEquals(ViewConfigCache.getViewDefinition(NavigationOverriding1.ForwardedPage1.class).getViewId(),
                                                       "/forwardedPage1.xhtml");

        ViewConfigEntry viewConfigEntry =ViewConfigCache.getViewDefinition(NavigationOverriding1.RedirectedPage1.class);
        assertEquals(viewConfigEntry.getNavigationMode(), NavigationMode.REDIRECT);

        viewConfigEntry = ViewConfigCache.getViewDefinition(NavigationOverriding1.ForwardedPage1.class);

        assertEquals(viewConfigEntry.getNavigationMode(), NavigationMode.FORWARD);
    }
View Full Code Here

        assertEquals(ViewConfigCache.getViewDefinition(NavigationOverriding2.RedirectedPage2.class).getViewId(),
                                                       "/redirectedPage2.xhtml");
        assertEquals(ViewConfigCache.getViewDefinition(NavigationOverriding2.ForwardedPage2.class).getViewId(),
                                                       "/forwardedPage2.xhtml");

        ViewConfigEntry viewConfigEntry =ViewConfigCache.getViewDefinition(NavigationOverriding2.RedirectedPage2.class);
        assertEquals(viewConfigEntry.getNavigationMode(), NavigationMode.REDIRECT);

        viewConfigEntry = ViewConfigCache.getViewDefinition(NavigationOverriding2.ForwardedPage2.class);

        assertEquals(viewConfigEntry.getNavigationMode(), NavigationMode.FORWARD);
    }
View Full Code Here

    public void testViewConfigWithAccessDecisionVoters()
    {
        viewConfigExtension.addPageDefinition(ViewConfigWithAccessDecisionVoters.Page1.class);
        viewConfigExtension.addPageDefinition(ViewConfigWithAccessDecisionVoters.Page2.class);

        ViewConfigEntry viewConfigEntry = ViewConfigCache.getViewDefinition(
                ViewConfigWithAccessDecisionVoters.Page1.class);

        assertEquals(viewConfigEntry.getAccessDecisionVoters().size(), 1);

        viewConfigEntry = ViewConfigCache.getViewDefinition(ViewConfigWithAccessDecisionVoters.Page2.class);

        assertEquals(viewConfigEntry.getAccessDecisionVoters().size(), 2);

        boolean voter2 = false;
        for(Class<? extends AccessDecisionVoter> accessDecisionVoter : viewConfigEntry.getAccessDecisionVoters())
        {
            if(!voter2)
            {
                assertTrue(accessDecisionVoter.equals(TestAccessDecisionVoter2.class));
                voter2 = true;
View Full Code Here

    public void testViewConfigWithSecurityErrorPages()
    {
        viewConfigExtension.addPageDefinition(ViewConfigWithSecurityErrorPages.Page1.class);
        viewConfigExtension.addPageDefinition(ViewConfigWithSecurityErrorPages.Page2.class);

        ViewConfigEntry viewConfigEntry = ViewConfigCache.getViewDefinition(
                ViewConfigWithSecurityErrorPages.Page1.class);

        assertEquals(viewConfigEntry.getErrorView(), SimpleView.class);

        viewConfigEntry = ViewConfigCache.getViewDefinition(ViewConfigWithSecurityErrorPages.Page2.class);
        assertEquals(viewConfigEntry.getErrorView(), SimpleViewWithManualName.class);
    }
View Full Code Here

    public void testViewConfigWithViewMetaData()
    {
        viewConfigExtension.addPageDefinition(ViewConfigWithViewMetaData.Page1.class);
        viewConfigExtension.addPageDefinition(ViewConfigWithViewMetaData.Page2.class);

        ViewConfigEntry viewConfigEntry = ViewConfigCache.getViewDefinition(
                ViewConfigWithViewMetaData.Page1.class);

        assertEquals(viewConfigEntry.getMetaData().size(), 2);

        viewConfigEntry = ViewConfigCache.getViewDefinition(ViewConfigWithViewMetaData.Page2.class);
        assertEquals(viewConfigEntry.getMetaData().size(), 3);
    }
View Full Code Here

    public void testViewConfigWithViewController()
    {
        viewConfigExtension.addPageDefinition(ViewConfigWithViewController.Page1.class);
        viewConfigExtension.addPageDefinition(ViewConfigWithViewController.Page2.class);

        ViewConfigEntry viewConfigEntry = ViewConfigCache.getViewDefinition(
                ViewConfigWithViewController.Page1.class);

        List<PageBeanConfigEntry> pageBeanConfigEntries = viewConfigEntry.getPageBeanDefinitions();
        assertEquals(pageBeanConfigEntries.size(), 1);
        assertTrue(pageBeanConfigEntries.iterator().next().getBeanClass().equals(TestPageBean2.class));

        viewConfigEntry = ViewConfigCache.getViewDefinition(ViewConfigWithViewController.Page2.class);

        pageBeanConfigEntries = viewConfigEntry.getPageBeanDefinitions();
        assertEquals(pageBeanConfigEntries.size(), 2);

        for(PageBeanConfigEntry pageBeanConfigEntry : pageBeanConfigEntries)
        {
            assertTrue(pageBeanConfigEntry.getBeanClass().equals(TestPageBean2.class) ||
View Full Code Here

            errorView = inlineErrorView;
        }

        if(errorView == null)
        {
            ViewConfigEntry errorPageEntry = ViewConfigCache.getDefaultErrorView();

            if(errorPageEntry != null)
            {
                errorView = errorPageEntry.getViewDefinitionClass();
            }
        }

        if(errorView == null)
        {
View Full Code Here

                //it isn't possible to support interfaces due to cdi restrictions
                if(outcome.startsWith("class "))
                {
                    outcome = outcome.substring(6);
                }
                ViewConfigEntry entry = this.viewConfigs.get(outcome);

                if(entry == null)
                {
                    if(DefaultErrorView.class.getName().equals(originalOutcome))
                    {
                        entry = ViewConfigCache.getDefaultErrorView();
                    }
                }
               
                if(entry == null)
                {
                    Object loadedClass = tryToLoadClassForName(outcome);

                    if(loadedClass == null)
                    {
                        this.otherOutcomes.add(originalOutcome);
                    }
                    else if(ViewConfig.class.isAssignableFrom((Class)loadedClass))
                    {
                        //noinspection unchecked
                        entry = ViewConfigCache.getViewDefinition((Class<? extends ViewConfig>)loadedClass);
                    }
                }

                if(entry != null)
                {
                    //security
                    try
                    {
                        invokeVoters(null, this.beanManager, entry.getAccessDecisionVoters(), entry.getErrorView());
                    }
                    catch (AccessDeniedException accessDeniedException)
                    {
                        tryToHandleSecurityViolation(accessDeniedException);
                        return;
View Full Code Here

    }

    private PreViewConfigNavigateEvent firePreViewConfigNavigateEvent(
            String oldViewId, ViewConfigEntry newViewConfigEntry)
    {
        ViewConfigEntry oldViewConfigEntry = ViewConfigCache.getViewDefinition(oldViewId);

        if(oldViewConfigEntry != null)
        {
            PreViewConfigNavigateEvent navigateEvent = new PreViewConfigNavigateEvent(
                    oldViewConfigEntry.getViewDefinitionClass(), newViewConfigEntry.getViewDefinitionClass());

            this.beanManager.fireEvent(navigateEvent);
            return navigateEvent;
        }
        return null;
View Full Code Here

TOP

Related Classes of org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.ViewConfigEntry

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.