Monday, October 28, 2013

How to use “Scheduler.get().scheduleDeferred” the right way in GWT?

Here is my Pseudocode in my GWT app.

-Visible the loading Label  -Loading text from properties file (may take long)  -Invisible the loading Label & Visible the main HTMLPanel  

So I want to use Scheduler.get().scheduleDeferred to achive that, here is the code:

loadingLabel.setVisible(true);  Scheduler.get().scheduleDeferred(new ScheduledCommand() {     @Override    public void execute() {     loadingText();    }  }  loadingLabel.setVisible(false);  mainHTMLPanel.setVisible(true);  

But it doesn't work correctly as it did not show the loadingLabel but show the mainHTMLPanel immediately & when i click a textbox inside the mainHTMLPanel since the Gui got frozen cos it is loading text. Then I have to wait for a while to be able to click the textbox inside mainHTMLPanel.

But if i put loadingLabel.setVisible(false); & mainHTMLPanel.setVisible(true); insideexecute() Then it works.

But i am not sure that is the right way to do.

So, is the following code the right way to use Scheduler.get().scheduleDeferred?

    loadingLabel.setVisible(true);      Scheduler.get().scheduleDeferred(new ScheduledCommand() {         @Override        public void execute() {         loadingText();         loadingLabel.setVisible(false);         mainHTMLPanel.setVisible(true);        }      }

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment