Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Problems with push to display notification from background thread
hello,
here is the sample code:
My UI subclass has an @Push annotation:
@SuppressWarnings("serial")
@Component
@Scope("prototype")
@Theme("custom")
@Push(transport = Transport.STREAMING)
@Widgetset("...")
@PreserveOnRefresh
public class CasePortalApplication extends UI {
I have a worker thread that calls executeDeletion():
logger.debug("Execute deletion");
new Thread(){
@Override
public void run() {
executeDeletion();
}
}.start();
logger.debug("Deletion executed");
and executeDeletion does a long running job and then displays a notification box:
private void executeDeletion()
{
// do long-running operation here!
casePortalApplication.access(new Runnable() {
@Override
public void run()
{
notifier.showNotification(message);
}
});
}
But the notification is not displayed (without the background thread and UI.access this did work fine).
There is no exception in the log.
Any ideas? (Tomorrow I will try to call UI.push() explicitly)
Thanks and Best Regards,
Felix
I tried a bit more:
- casePortalApplication.push() does not help
- calling notifier.showNotification(message); directly (i.e. not from access() Runnable) works
Can you post more code? What you have posted works for me.
By the way Transport.STREAMING is deprecated in favor of Transport.LONG_POLLING
hello Marco,
What works for you? The direct call to notifier.showNotification() or the
ui.access() solution? I am not sure the direct call works in all cases :-/
I will try LONG_POLLING for the next stable release.
Thanks and Best Regards,
Felix