Send changes to ALL UIs

Hello,

I have a simple question:
In my case: How can I show a notification to all ui?

Thanks

Here’s how to send a notification to all pages - however, this will not get “pushed” to all browser tabs, just to the one that this code is called from. For that, you’ll need to wait for Vaadin Push (or use the Refresher add-on)

Cheers,

Charles.

/* Build a set of all the pages */
Set<Page> pages = new HashSet<Page>();
Collection<UI> uIs = VaadinSession.getCurrent().getUIs();
for (UI ui : uIs) {
  pages.add(ui.getPage());
}

/* Show a notification on all the pages */
Notification notification = new Notification("Sample Notification", Notification.Type.HUMANIZED_MESSAGE);
for (Page page : pages) {
  notification.show(page);
}

Hey Charles,

thank you :slight_smile: