org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver Java Examples

The following examples show how to use org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ViewConfigPathTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Test
public void testNamesWizard4()
{
    this.viewConfigExtension.addPageDefinition(Pages.Wizard4.Step1.class);
    this.viewConfigExtension.addPageDefinition(Pages.Wizard4.Step2.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();

    ViewConfigDescriptor viewConfigDescriptor;


    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard4.Step1.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/wizard4/step1.xhtml", viewConfigDescriptor.getViewId());

    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard4.Step2.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/step2.xhtml", viewConfigDescriptor.getViewId());
}
 
Example #2
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleViewConfigWithViewControllerCallback()
{
    this.viewConfigExtension.addPageDefinition(SimplePageConfig.class);
    this.viewConfigExtension.addIndirectlyInheritedMetaData(PageBean003.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.class);

    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, InitView.class));
    Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreViewAction.class));
    Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class));
    Assert.assertNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PostRenderView.class));

    Assert.assertEquals(PageBean003.class, viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, InitView.class).getCallbackMethods().keySet().iterator().next());
    Assert.assertEquals("callbackMethod1", ((List<Method>) viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, InitView.class).getCallbackMethods().values().iterator().next()).iterator().next().getName());

    Assert.assertEquals(PageBean003.class, viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreViewAction.class).getCallbackMethods().keySet().iterator().next());
    Assert.assertEquals("callbackMethod1", ((List<Method>) viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreViewAction.class).getCallbackMethods().values().iterator().next()).iterator().next().getName());

    Assert.assertEquals(PageBean003.class, viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class).getCallbackMethods().keySet().iterator().next());
    Assert.assertEquals("callbackMethod2", ((List<Method>) viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class).getCallbackMethods().values().iterator().next()).iterator().next().getName());
}
 
Example #3
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleViewConfigWithExplicitPageMetaData()
{
    this.viewConfigExtension.addPageDefinition(SimplePageConfig002.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig002.class);

    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/simplePageConfig002.xhtml", viewConfigDescriptor.getViewId());
    Assert.assertEquals(SimplePageConfig002.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());

    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size());
}
 
Example #4
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleViewConfigWithOptionalPageMetaData()
{
    this.viewConfigExtension.addPageDefinition(SimplePageConfig001.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig001.class);

    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/simplePageConfig001.xhtml", viewConfigDescriptor.getViewId());
    Assert.assertEquals(SimplePageConfig001.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());

    //@View gets added autom. if it isn't provided in-/directly
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size());
}
 
Example #5
Source File: ViewConfigPathValidatorTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Test
public void testMissingPathButUnsupportedExtension()
{
    this.viewConfigExtension.addPageDefinition(Pages.Index.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();

    List<String> supportedExtensions = new ArrayList<String>();
    supportedExtensions.add(View.Extension.JSF);

    try
    {
        new MockedViewConfigPathValidator(false).validateViewConfigPaths(null, viewConfigResolver, supportedExtensions);
    }
    catch (Exception e)
    {
        Assert.fail("unsupported extension wasn't ignored");
    }
}
 
Example #6
Source File: ViewConfigPathValidatorTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Test
public void testValidViewConfig()
{
    this.viewConfigExtension.addPageDefinition(Pages.Index.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();

    List<String> supportedExtensions = new ArrayList<String>();
    supportedExtensions.add(View.Extension.XHTML);

    try
    {
        new MockedViewConfigPathValidator(true).validateViewConfigPaths(null, viewConfigResolver, supportedExtensions);
    }
    catch (Exception e)
    {
        Assert.fail("valid view-config was reported as invalid");
    }
}
 
Example #7
Source File: ViewConfigPathTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Test
public void testNamesWizard3()
{
    this.viewConfigExtension.addPageDefinition(Pages.Wizard3.Step1.class);
    this.viewConfigExtension.addPageDefinition(Pages.Wizard3.Step2.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();

    ViewConfigDescriptor viewConfigDescriptor;


    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard3.Step1.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/wizard3/step1.xhtml", viewConfigDescriptor.getViewId());

    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard3.Step2.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/step2.xhtml", viewConfigDescriptor.getViewId());
}
 
Example #8
Source File: ViewConfigPathValidator.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Override
public void contextInitialized(ServletContextEvent sce)
{
    if (ClassDeactivationUtils.isActivated(getClass()))
    {
        ViewConfigResolver viewConfigResolver;

        try
        {
            viewConfigResolver = BeanProvider.getContextualReference(ViewConfigResolver.class);
        }
        catch (Exception e)
        {
            LOGGER.log(Level.WARNING, "Container issue detected -> can't validate view-configs. " +
                "This exception is usually the effect (but not the reason) of a failed startup. " +
                "You can deactivate " + getClass().getName() + " via a custom " +
                ClassDeactivator.class.getName() + " to verify it.", e);
            return;
        }

        List<String> supportedExtensions = new ArrayList<String>();
        supportedExtensions.add(View.Extension.XHTML);
        supportedExtensions.add(View.Extension.JSP);
        validateViewConfigPaths(sce, viewConfigResolver, supportedExtensions);
    }
}
 
Example #9
Source File: ViewConfigResolverProducer.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Produces
@ApplicationScoped
public ViewConfigResolver createViewConfigResolver()
{
    if (!viewConfigExtension.isActivated())
    {
        return createEmptyDefaultViewConfigResolver();
    }

    if (!viewConfigExtension.isTransformed()) //esp. for easier unit-tests
    {
        viewConfigExtension.transformMetaDataTree();
    }
    ViewConfigResolver viewConfigResolver = viewConfigExtension.getViewConfigResolver();

    if (viewConfigResolver == null)
    {
        LOG.warning("It wasn't possible to create a ViewConfigResolver");
        viewConfigResolver = createEmptyDefaultViewConfigResolver();
    }

    return viewConfigResolver;
}
 
Example #10
Source File: DeltaSpikePhaseListener.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
private synchronized void lazyInit()
{
    if (this.viewConfigResolver != null)
    {
        return;
    }

    this.securityModuleActivated =
        BeanProvider.getContextualReference(EditableAccessDecisionVoterContext.class, true) != null;

    this.viewConfigResolver = BeanProvider.getContextualReference(ViewConfigResolver.class);

    if (!this.securityModuleActivated)
    {
        Logger.getLogger(getClass().getName()) //it's the only case for which a logger is needed in this class
                .info("security-module-impl isn't used -> " + getClass().getName() +
                        "#checkSecuredView gets deactivated");
    }
}
 
Example #11
Source File: ViewConfigPathTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testNamesWizard7()
{
    this.viewConfigExtension.addPageDefinition(Pages.Wizard7.Step1.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();

    ViewConfigDescriptor viewConfigDescriptor;


    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard7.Step1.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/wizard7/step1.xhtml", viewConfigDescriptor.getViewId());
}
 
Example #12
Source File: ViewConfigPathTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testNamesWizard6()
{
    this.viewConfigExtension.addPageDefinition(Pages.Wizard6.Step1.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();

    ViewConfigDescriptor viewConfigDescriptor;


    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard6.Step1.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/wizard6/step1.xhtml", viewConfigDescriptor.getViewId());
}
 
Example #13
Source File: ViewConfigPathTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testNamesWizard5()
{
    this.viewConfigExtension.addPageDefinition(Pages.Wizard5.Step1.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();

    ViewConfigDescriptor viewConfigDescriptor;


    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard5.Step1.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/wizard5/step1.xhtml", viewConfigDescriptor.getViewId());
}
 
Example #14
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testViewConfigWithStereotypeMetaData()
{
    this.viewConfigExtension.addPageDefinition(Pages.Home.class);
    this.viewConfigExtension.addPageDefinition(Pages.Public.Index.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();


    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Home.class);

    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation());
    Assert.assertEquals(View.ViewParameterMode.INCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams());


    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Public.Index.class);

    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation());
    Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams());
}
 
Example #15
Source File: ViewConfigPathTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testNamesWizard8()
{
    this.viewConfigExtension.addPageDefinition(Pages.Wizard8.Step1.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();

    ViewConfigDescriptor viewConfigDescriptor;


    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard8.Step1.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/w8/step1.xhtml", viewConfigDescriptor.getViewId());
}
 
Example #16
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testViewConfigWithStereotypeMetaData()
{
    this.viewConfigExtension.addPageDefinition(Pages.Home.class);
    this.viewConfigExtension.addPageDefinition(Pages.Public.Index.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();


    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Home.class);

    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(2, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData(MyView.class).size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation());
    Assert.assertEquals(View.ViewParameterMode.INCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams());
    Assert.assertEquals("landing page", viewConfigDescriptor.getMetaData(MyView.class).iterator().next().description());


    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Public.Index.class);

    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(2, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData(MyView.class).size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation());
    Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams());
    Assert.assertEquals("public content", viewConfigDescriptor.getMetaData(MyView.class).iterator().next().description());
}
 
Example #17
Source File: ViewConfigPathTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalStateException.class)
public void testNamesWizard14()
{
    this.viewConfigExtension.addPageDefinition(Pages.Wizard14.Step1.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();

    viewConfigResolver.getViewConfigDescriptor(Pages.Wizard14.Step1.class);
}
 
Example #18
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultErrorViewInViewConfig()
{
    this.viewConfigExtension.addPageDefinition(Pages.Index.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();

    Assert.assertNotNull(viewConfigResolver.getDefaultErrorViewConfigDescriptor());
    Assert.assertEquals(Pages.Index.class, viewConfigResolver.getDefaultErrorViewConfigDescriptor().getConfigClass());
    Assert.assertEquals(Pages.Index.class, viewConfigResolver.getViewConfigDescriptor(DefaultErrorView.class).getConfigClass());
}
 
Example #19
Source File: ViewConfigPathTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testNamesWizard9()
{
    this.viewConfigExtension.addPageDefinition(Pages.Wizard9.Step1.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();

    ViewConfigDescriptor viewConfigDescriptor;


    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard9.Step1.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/w9/step1.xhtml", viewConfigDescriptor.getViewId());
}
 
Example #20
Source File: ViewConfigPathTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testNamesWizard10()
{
    this.viewConfigExtension.addPageDefinition(Pages.Wizard10.Step1.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();

    ViewConfigDescriptor viewConfigDescriptor;


    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard10.Step1.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/w10a/step1.xhtml", viewConfigDescriptor.getViewId());
}
 
Example #21
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleViewConfigWithViewControllerCallback()
{
    this.viewConfigExtension.addPageDefinition(SimplePageConfig.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.class);

    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PostRenderView.class));
    Assert.assertEquals(PageBean002.class, viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PostRenderView.class).getCallbackMethods().keySet().iterator().next());
    Assert.assertEquals("postRenderViewCallbackMethod", ((List<Method>) viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PostRenderView.class).getCallbackMethods().values().iterator().next()).iterator().next().getName());
}
 
Example #22
Source File: ViewConfigPathValidatorTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Override
public void validateViewConfigPaths(ServletContextEvent sce,
                                    ViewConfigResolver viewConfigResolver,
                                    List<String> supportedExtensions)
{
    super.validateViewConfigPaths(sce, viewConfigResolver, supportedExtensions);
}
 
Example #23
Source File: ViewConfigPathValidatorTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalStateException.class)
public void testMissingPath()
{
    this.viewConfigExtension.addPageDefinition(Pages.Index.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();

    List<String> supportedExtensions = new ArrayList<String>();
    supportedExtensions.add(View.Extension.XHTML);
    new MockedViewConfigPathValidator(false).validateViewConfigPaths(null, viewConfigResolver, supportedExtensions);
}
 
Example #24
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleViewConfigWithViewControllerCallback()
{
    this.viewConfigExtension.addPageDefinition(SimplePageConfig.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.class);

    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class));
    Assert.assertEquals(PageBean001.class, viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class).getCallbackMethods().keySet().iterator().next());
    Assert.assertEquals("preRenderViewCallbackMethod", ((List<Method>) viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class).getCallbackMethods().values().iterator().next()).iterator().next().getName());
}
 
Example #25
Source File: SecurityUtils.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private static void tryToHandleSecurityViolation(RuntimeException runtimeException,
                                                 boolean allowNavigation)
{
    ErrorViewAwareAccessDeniedException exception = extractException(runtimeException);

    if (exception == null)
    {
        throw runtimeException;
    }

    Class<? extends ViewConfig> errorView = null;

    Class<? extends ViewConfig> inlineErrorView = exception.getErrorView();

    if (inlineErrorView != null && !DefaultErrorView.class.getName().equals(inlineErrorView.getName()))
    {
        errorView = inlineErrorView;
    }

    if (errorView == null)
    {
        ViewConfigResolver viewConfigResolver = BeanProvider.getContextualReference(ViewConfigResolver.class);
        ViewConfigDescriptor errorPageDescriptor = viewConfigResolver.getDefaultErrorViewConfigDescriptor();

        if (errorPageDescriptor != null)
        {
            errorView = errorPageDescriptor.getConfigClass();
        }
    }

    if (errorView == null && allowNavigation)
    {
        throw exception;
    }

    processApplicationSecurityException(exception, errorView, allowNavigation);
}
 
Example #26
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleViewConfigWithCallbacks()
{
    this.viewConfigExtension.addPageDefinition(SimplePageConfig.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.class);

    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, InitView.class));
    Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class));
    Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(TestSecured.class));
}
 
Example #27
Source File: ViewConfigExtension.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private ViewConfigResolver createCustomViewConfigResolver(ViewConfigRoot viewConfigRoot,
                                                          ConfigNodeConverter configNodeConverter,
                                                          ViewConfigInheritanceStrategy inheritanceStrategy,
                                                          List<ConfigDescriptorValidator> validators)
{
    Class<? extends ViewConfigResolver> viewConfigResolverClass = viewConfigRoot.viewConfigResolver();
    if (!ViewConfigResolver.class.equals(viewConfigResolverClass))
    {
        try
        {
            Constructor<? extends ViewConfigResolver> viewConfigResolverConstructor = viewConfigResolverClass
                    .getConstructor(new Class[]{
                        ViewConfigNode.class,
                        ConfigNodeConverter.class,
                        ViewConfigInheritanceStrategy.class,
                        List.class});

            return viewConfigResolverConstructor
                    .newInstance(this.rootViewConfigNode, configNodeConverter, inheritanceStrategy, validators);
        }
        catch (Exception e)
        {
            throw ExceptionUtils.throwAsRuntimeException(e);
        }
    }
    return null;
}
 
Example #28
Source File: ViewConfigAwareNavigationHandler.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private synchronized void init()
{
    if (this.beanManager == null)
    {
        this.navigationParameterContext =
                BeanProvider.getContextualReference(NavigationParameterContext.class);
        this.viewConfigResolver =
                BeanProvider.getContextualReference(ViewConfigResolver.class);

        this.beanManager = BeanManagerProvider.getInstance().getBeanManager();
    }
}
 
Example #29
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testViewConfigWithRandomOrder()
{
    this.viewConfigExtension.addPageDefinition(Pages.Index.class);
    this.viewConfigExtension.addPageDefinition(Pages.class); //simulates random processing-order

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Index.class);

    Assert.assertEquals("/pages/index.xhtml", viewConfigDescriptor.getViewId());
    Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams());
}
 
Example #30
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testViewConfigCustomViewConfigPreProcessor()
{
    this.viewConfigExtension.addPageDefinition(Pages.Public.Index.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Public.Index.class);

    //changed by TestConfigPreProcessor
    Assert.assertEquals("/test/view.custom", viewConfigDescriptor.getViewId());
    Assert.assertEquals(View.ViewParameterMode.DEFAULT, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams());
}