Callback from opened Window

Is it possible to get some kind of callback from a Window when it has been opened and shown?

Hi,

Not exactly like that, no - there is no listener for that specific event.

However, we might be able to help figuring out another way to achieve the desired result, if you want to provide more detail about what you’re trying to do.

Best Regards,
Marc

I want to open a Window with a ProgressIndicator in. Then when the window is opened and shown in the user’s browser, I want to start updating the ProgressIndicator on the progess of a time-consuming computation and eventually display the result from the time-consuming process in the window.

It is important that the user see the opened window with ProgressIndicator before the time-consuming computation is finished.

The window is opened in a Vaadin event handler (such as a ClickListener from a Button). It did not work to do the computation within the event handler, since the window is not actually opened until the event handler returns.

BTW, does Vaadin have anything similar to SwingWorker or SwingUtilites.{invokeLater(), invokeAndWait()}?

Hi,

You need to start the time-consuming process in a separate thread so that your UI does not block. And since you’ll be doing that, you can safely start the thread in the ClickListener and start updating the ProgressIndicator as needed.

Best Regards,
Marc


Edit: Oh, and remember to synchronize on the application instance if the other thread updates the UI.

OK, then I know how to do it.

However, it seems a bit old-fashioned to have to resort to low-level thread handling. Especially since you are not really supposed to create your own threads in a JavaEE application server (accoring to the JavaEE spec).

Perhaps Vaadin needs something like SwingWorker to abstract away the low-level thread handling.