Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For further details about DemoPage.class please have a look at the view-config section.

Note
titleHint

If you don't need the PhaseEvent as parameter, you can just annotate your methods with @BeforePhase(...) and @AfterPhase(...).

Note
titleHint

@View is an interceptor. The disadvantage is that intercepted beans introduce an overhead.
If you would like to use this mechanism for implementing pre-render view logic, you should think about using the @PageBean annotation.
Further details are available in the view-config section.

...

CODI allows to specify the page-bean as optional meta-data via the view-config mechanism.
You can use this approach to load the page-bean before the rendering process starts. So the post-construct method (= methods annotated with @PostConstruct) will be invoked if it is needed. Furthermore, it's possible to use @BeforePhase(...) and @AfterPhase(...) without observer syntax of CDI.

Code Block
java
java
titleView-config with Page-Bean

@PageBean(LoginPage.class)
@Page
public final class Login implements ViewConfig
{
}
Code Block
java
java
titlePage-Bean

//...
public final class LoginPage implements Serializable
{
  @PostConstruct
  protected void initBean()
  {
    //...
  }

  @AfterPhase(INVOKE_APPLICATION)
  protected void postPageAction()
  {
    //...
  }

  @BeforePhase(RENDER_RESPONSE)
  protected void preRenderView()
  {
    //...
  }
}

... you can use @BeforePhase and @AfterPhase in the same way like the Phase-Listener Methods described above (just without the need of the PhaseEvent).

Code Block
java
java
titlePage-Bean with alias annotations

//...
public final class LoginPage implements Serializable
{
  @PostConstruct
  protected void initBean()
  {
    //...
  }

  @PreProcess
  protected void prePageAction()
  {
    //...
  }

  @PreRenderView
  protected void preRenderView()
  {
    //...
  }
}

@PreProcess is invoked directly before the action-method. In comparison to @BeforePhase(INVOKE_APPLICATION), @PreProcess also works for immediate actions.

Note
titleHint

For normal pre-render view logic you can use phase-listener methods in combination with @View.
Attention: the performance depends on the interceptor-performance of your CDI implementation.