Package io.jmix.flowui
Class UiEventPublisher
java.lang.Object
io.jmix.flowui.UiEventPublisher
Sends application events that should be handled in the components (e.g. views). To enable handling
application events in the
View
, annotate a method with EventListener
. For instance:
@EventListener public void customUiEventHandler(CustomUiEvent event) { // handle event }To correctly update the UI, class that implements
AppShellConfigurator
should contain the Push
annotation. It can be the main Spring Boot application class:
@Push @SpringBootApplication public class MyDemoProjectApplication implements AppShellConfigurator { // configuration }
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Event that should be processed on UI of specific users (or all users if usernames collection is null) -
Field Summary
Modifier and TypeFieldDescriptionprotected ClusterApplicationEventPublisher
protected SessionHolder
protected SystemAuthenticator
-
Constructor Summary
ConstructorDescriptionUiEventPublisher
(SystemAuthenticator systemAuthenticator, ClusterApplicationEventPublisher clusterApplicationEventPublisher, SessionHolder sessionHolder) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
onSessionAccess
(com.vaadin.flow.server.VaadinSession session, org.springframework.context.ApplicationEvent event) void
protected void
publish
(Collection<com.vaadin.flow.component.UI> uis, org.springframework.context.ApplicationEvent event) void
publishEvent
(org.springframework.context.ApplicationEvent event) Publishes event for all UIs in the current session.void
publishEventForCurrentUI
(org.springframework.context.ApplicationEvent event) Publishes event only for the current UI.void
publishEventForUsers
(org.springframework.context.ApplicationEvent event, Collection<String> usernames) Publishes the event for all UIs in all sessions of users specified in usernames collection.protected void
publishEventForUsersInternal
(org.springframework.context.ApplicationEvent event, Collection<String> usernames) protected void
sendEventToUserSessions
(org.springframework.context.ApplicationEvent event, Map<String, List<com.vaadin.flow.server.VaadinSession>> userSessions)
-
Field Details
-
systemAuthenticator
-
clusterApplicationEventPublisher
-
sessionHolder
-
-
Constructor Details
-
UiEventPublisher
public UiEventPublisher(SystemAuthenticator systemAuthenticator, ClusterApplicationEventPublisher clusterApplicationEventPublisher, SessionHolder sessionHolder)
-
-
Method Details
-
onUiUserEvent
-
publishEventForUsersInternal
protected void publishEventForUsersInternal(org.springframework.context.ApplicationEvent event, @Nullable Collection<String> usernames) -
sendEventToUserSessions
-
onSessionAccess
protected void onSessionAccess(com.vaadin.flow.server.VaadinSession session, org.springframework.context.ApplicationEvent event) -
publishEventForCurrentUI
public void publishEventForCurrentUI(org.springframework.context.ApplicationEvent event) Publishes event only for the current UI.- Parameters:
event
- application event
-
publishEvent
public void publishEvent(org.springframework.context.ApplicationEvent event) Publishes event for all UIs in the current session.- Parameters:
event
- application event
-
publish
protected void publish(Collection<com.vaadin.flow.component.UI> uis, org.springframework.context.ApplicationEvent event) -
publishEventForUsers
public void publishEventForUsers(org.springframework.context.ApplicationEvent event, @Nullable Collection<String> usernames) Publishes the event for all UIs in all sessions of users specified in usernames collection. If usernames collection is null the event will be published for all users.- Parameters:
event
- event to publishusernames
- usernames of target users or null if broadcast to all users is needed
-