Observable Vaadin Events
The Vaadin CDI add-on publishes many Vaadin events to CDI.
It is not necessary to register a listener, using only an observer is sufficient to handle these events.
Events published to CDI include:
-
ServiceInitEventSee VaadinServiceInitListener for more. -
PollEvent. -
BeforeEnterEvent. See Navigation Lifecycle for more. -
BeforeLeaveEvent. See Navigation Lifecycle for more. -
AfterNavigationEvent. See Navigation Lifecycle for more. -
UIInitEvent. See UIInitListener for more. -
SessionInitEvent. See Handling Session Initialization and Destruction for more. -
SessionDestroyEvent. See Handling Session Initialization and Destruction for more. -
ServiceDestroyEvent.
|
Warning
|
Whether or not ServiceDestroyEvent works with CDI during application shutdown depends on each specific implementation.
|
Example: Using the @Observes annotation to listen ServiceInitEvent.
Source code
Java
public class BootstrapCustomizer {
private void onServiceInit(@Observes
ServiceInitEvent serviceInitEvent) {
serviceInitEvent.addBootstrapListener(
this::modifyBootstrapPage);
}
private void modifyBootstrapPage(
BootstrapPageResponse response) {
response.getDocument().body().append(
"<p>By CDI add-on</p>");
}
}5C2A63A8-3768-45A6-B2C3-B09DFC114E5A