Notify User from Background Thread?

I know there are millions of questions like this, but they all come to having to call UI.getCurrent().access(…) and in my case UI.getCurrent() returns null. The same goes for VaadinSesscion.getCurrent() - also null. I am calling it from a Spring AsyncUncaughtExceptionHandler.[omegle]
( [xender]

Basically, this is a bean that comes to life every time an exception occurs in an @Async annotated method (such as sending a mail). The handler thread is instantiated by Spring, so I have no way of passing it a Vaadin UI or Component.

So, is it possible to display any kind of error message to the user from a non-Vaadin thread?

There should at least be a way with JavaScript or such.

You can check this documentation:

Bascially a Vaadin view that could notify a user will subscribe to the Broadcaster. (You can do it on the MainLayout if you want it for the entire application).

Any Java class can call Broadcaster.broadcast since it’s a static method.

No need for Javascript :slight_smile:

Yes so the fundental question is “which UI do you want to show the notification in?”. The framework cannot know that, you need to tell it.

A UI corresponds to a browser tab where some view is open so with many users having potentially many tabs open there would be a lot of UI instances to choose from