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

Does anybody have an idea? Many Thanks in advance!!

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

The ui.access() solution works for me