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

The following examples show how to use org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor. 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: ViewControllerUtils.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
public static void executeViewControllerCallback(ViewConfigDescriptor viewDefinitionEntry,
                                                 Class<? extends Annotation> callbackType)
{
    if (viewDefinitionEntry == null)
    {
        return;
    }

    SimpleCallbackDescriptor initViewCallbackDescriptor = viewDefinitionEntry.getExecutableCallbackDescriptor(
            ViewControllerRef.class, callbackType, SimpleCallbackDescriptor.class);

    if (initViewCallbackDescriptor != null)
    {
        initViewCallbackDescriptor.execute();
    }
}
 
Example #2
Source File: ViewConfigAwareNavigationHandler.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
private PreViewConfigNavigateEvent firePreViewConfigNavigateEvent(String oldViewId,
                                                                  ViewConfigDescriptor newViewConfigDescriptor)
{
    ViewConfigDescriptor oldViewConfigDescriptor = this.viewConfigResolver.getViewConfigDescriptor(oldViewId);

    PreViewConfigNavigateEvent navigateEvent;

    if (oldViewConfigDescriptor != null)
    {
        navigateEvent = new PreViewConfigNavigateEvent(
                oldViewConfigDescriptor.getConfigClass(), newViewConfigDescriptor.getConfigClass());
    }
    else
    {
        navigateEvent = new PreViewConfigNavigateEvent(
                ViewRef.Manual.class, newViewConfigDescriptor.getConfigClass());
    }

    this.beanManager.fireEvent(navigateEvent);
    return navigateEvent;
}
 
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 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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleViewConfigWithCustomMetaData()
{
    this.viewConfigExtension.addPageDefinition(SimplePageConfig.class);

    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.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(TestEntryPoint.class).size());
}
 
Example #14
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 #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: 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 #17
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 #18
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 #19
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 #20
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 #21
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 #22
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());
}
 
Example #23
Source File: ViewConfigAwareNavigationHandler.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private ViewConfigDescriptor tryToUpdateEntry(ViewConfigDescriptor viewConfigDescriptor,
                                              PreViewConfigNavigateEvent navigateEvent)
{
    if (navigateEvent.getToView() == null)
    {
        return null;
    }

    if (navigateEvent.getToView().equals(viewConfigDescriptor.getConfigClass()))
    {
        return viewConfigDescriptor;
    }

    return this.viewConfigResolver.getViewConfigDescriptor(navigateEvent.getToView());
}
 
Example #24
Source File: InfoBean.java    From tomee with Apache License 2.0 5 votes vote down vote up
public boolean isInfoPage() {
    ViewConfigDescriptor viewConfigDescriptor =
            this.viewConfigResolver.getViewConfigDescriptor(FacesContext.getCurrentInstance().getViewRoot().getViewId());

    if (viewConfigDescriptor == null) {
        return false;
    }

    return !viewConfigDescriptor.getMetaData(InfoPage.class).isEmpty();
}
 
Example #25
Source File: DeltaSpikePhaseListener.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private void processInitView(String viewId)
{
    try
    {
        WindowMetaData windowMetaData = BeanProvider.getContextualReference(WindowMetaData.class);

        //view already initialized in this or any prev. request
        if (viewId.equals(windowMetaData.getInitializedViewId()))
        {
            return;
        }

        //override the view-id if we have a new view
        windowMetaData.setInitializedViewId(viewId);

        ViewConfigDescriptor viewDefinitionEntry = this.viewConfigResolver.getViewConfigDescriptor(viewId);

        if (viewDefinitionEntry == null)
        {
            return;
        }

        ViewControllerUtils.executeViewControllerCallback(viewDefinitionEntry, InitView.class);
    }
    catch (ContextNotActiveException e)
    {
        //TODO discuss how we handle it
    }
}
 
Example #26
Source File: DeltaSpikePhaseListener.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private void processPreRenderView(FacesContext facesContext)
{
    UIViewRoot uiViewRoot = facesContext.getViewRoot();

    if (uiViewRoot != null)
    {
        ViewConfigDescriptor viewDefinitionEntry =
                this.viewConfigResolver.getViewConfigDescriptor(uiViewRoot.getViewId());

        ViewControllerUtils.executeViewControllerCallback(viewDefinitionEntry, PreRenderView.class);
    }
}
 
Example #27
Source File: DeltaSpikePhaseListener.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private void processPostRenderView(FacesContext facesContext)
{
    UIViewRoot uiViewRoot = facesContext.getViewRoot();

    if (uiViewRoot != null)
    {
        ViewConfigDescriptor viewDefinitionEntry =
                this.viewConfigResolver.getViewConfigDescriptor(uiViewRoot.getViewId());

        ViewControllerUtils.executeViewControllerCallback(viewDefinitionEntry, PostRenderView.class);
    }
}
 
Example #28
Source File: DefaultViewConfigResolver.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Override
public ViewConfigDescriptor getViewConfigDescriptor(String viewId)
{
    if (viewId == null)
    {
        return null;
    }

    return this.viewPathToViewDefinitionEntryMapping.get(viewId);
}
 
Example #29
Source File: DefaultViewConfigResolver.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Override
public ViewConfigDescriptor getViewConfigDescriptor(Class<? extends ViewConfig> viewDefinitionClass)
{
    if (DefaultErrorView.class.equals(viewDefinitionClass))
    {
        return getDefaultErrorViewConfigDescriptor();
    }
    return this.viewDefinitionToViewDefinitionEntryMapping.get(viewDefinitionClass);
}
 
Example #30
Source File: DefaultViewConfigResolver.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Override
public List<ViewConfigDescriptor> getViewConfigDescriptors()
{
    ViewConfigDescriptor[] result = this.viewDefinitionToViewDefinitionEntryMapping.values()
            .toArray(new ViewConfigDescriptor[this.viewDefinitionToViewDefinitionEntryMapping.size()]);

    return new ArrayList<ViewConfigDescriptor>(Arrays.asList(result));
}