Versions Compared

Key

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

...

Life-cycle Annotations

Phase-Listener Methods

As an alternative to a full phase-listener CODI allows to use observers as phase-listener methods.

Example:

Code Block
java
java
titleGlobal observer method for phase-events

protected void observePreRenderView(@Observes @BeforePhase(PhaseId.RENDER_RESPONSE) PhaseEvent phaseEvent)
{
  //...
}

If you would like to restrict the invocation to a specific view, it's possible to use the optional @View annotation.

Code Block
java
java
titleObserver method for phase-events for a specific view

@View(DemoPage.class)
public void observePostInvokeApplication(@Observes @AfterPhase(PhaseId.INVOKE_APPLICATION) PhaseEvent event)
{
  //...
}

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

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.

Phase-Listener

CODI provides an annotation for phase-listeners:

...