How to show "Loading..." style of messages with long running tasks

I’m doing an application with long running searches and I would like to show a simple message with “Searching… please wait.” kind of feedback after search has been initiated.

How do I force an UI update? Is it possible to do it in same thread or do I need to spawn a new thread to do the search and then update the ui?
But then how do I force UI update after the search thread completes?

Example:


Button b = new Button("Search", new ClickListener() {
  // Show the info
  _infoDisplayAboutWorking.setVisible(true);
  // force UI update?

  // do the search...

  // OK, search done.
  _infoDisplayAboutWorking.setVisible(false);
});

Sorry if this is a beginners question - just started experimenting with the toolkit.

With kind regards,
-Mark

Hi Mark,

Basically, you don’t need to worry about updating the UI, but you have to poll the server to see if there are some pending updates there.

Here is a suggestion how to do this using the
ProgressIndicator
:


_infoDisplayAboutWorking.setVisible(true); 

// Use a ProgressIndicator to poll the server 
final ProgressIndicator poller = new ProgressIndicator(new Float(0.0)); 
poller.setPollingInterval(2000); // Poll server for changes every 2 secs
mylayout.addComponent(poller);

// Do the search in separate thread
Thread worker = new Thread() {
   public void run() {

      // do the search... 

      // OK, search done. 
      _infoDisplayAboutWorking.setVisible(false); 
      mylayout.removeComponent(poller);
   }
}
worker.start();

Here is also a post how to hide the indicator: http://forum.itmill.com/posts/list/606.page

Thank you - this works beautifully.

-Mark