Observable Vaadin Events
Le module complémentaire Vaadin CDI publie de nombreux événements Vaadin vers contexts and dependency injection (CDI).
Il n’est pas nécessaire d’enregistrer un listener. Il suffit de gérer ces événements en utilisant uniquement un observer.
Les événements publiés vers CDI incluent :
-
ServiceInitEventVoir VaadinServiceInitListener pour plus d’informations. -
PollEvent. -
BeforeEnterEvent. Voir Navigation Lifecycle pour plus d’informations. -
BeforeLeaveEvent. Voir Navigation Lifecycle pour plus d’informations. -
AfterNavigationEvent. Voir Navigation Lifecycle pour plus d’informations. -
UIInitEvent. Voir Session and UI InitListener pour plus d’informations. -
SessionInitEvent. Voir Handling Session Initialization and Destruction pour plus d’informations. -
SessionDestroyEvent. Voir Handling Session Initialization and Destruction pour plus d’informations. -
ServiceDestroyEvent.
|
Warning
|
La prise en charge de ServiceDestroyEvent pendant l’arrêt de l’application dépend de chaque implémentation spécifique.
|
L’exemple ici utilise l’annotation @Observes pour écouter ServiceInitEvent :
Source code
Java
public class BootstrapCustomizer {
private void onServiceInit(@Observes
ServiceInitEvent serviceInitEvent) {
serviceInitEvent.addIndexHtmlRequestListener(
this::modifyBootstrapPage);
}
private void modifyBootstrapPage(
IndexHtmlResponse response) {
response.getDocument().body().append(
"<p>By CDI add-on</p>");
}
}DD8861A6-C281-4A3D-977D-FA750E3BAB5E