Below are my assumptions, and may not be the exact way it works.....

As you have already found out, many commands that change the DOM or
the visual display seem to be actually sent to an execution queue for
execution later.  Often times this queue has pending commands, and is
polled  later on.  This polling, seems to occur when the browser is
idle, or waiting for user interaction.  So if you command a popup to
display, the re-writing of the DOM is immediately queued up.   However
if you immediately continue executing javascript code in a loop or a
long algorithm, the browser will not poll the queue until your code is
completed.  (The popup  shows up after your code completes instead of
before it completes!)

That is why you will find that DeferredCommand is your friend.   If
you need to display a 'Please Wait' panel before doing some long task,
and then remove the 'Please Wait'  after  the task is finished you
will often need to use a DeferredCommand to execute the long running
code, and hide the 'Please Wait' panel  (Exactly as you have done in
your code).

It's a little frustrating.. because looking at your code, it is not
obvious that the code is not executing in the exact order you think it
should.  But if you are working with a large application, you will be
using DeferredCommand quite a bit.

Mike.





On Sep 28, 10:19 am, The Question <[email protected]> wrote:
> Hi,
>
> This is the method that I'm using to show a PopupPanel.
>
> --------------------------------------------------------
> private PopupPanel loadingPopup = new PopupPanel(false, true);
> this.loadingPopup.setWidget(getLoadingWidget());
>
> private void showLoading(final Boolean loading)
>     {
>         if (loading)
>         {
>             this.addStyleName(waitCursorStyle);
>
>             this.loadingPopup.center();
>             //if table header is already displayed, show
>             //the loading message in the table.
>             if (ResultSetTable.this.loadingTop != 0)
>             {
>                 this.loadingPopup.setPopupPosition(
>                         this.loadingPopup.getPopupLeft(),
>                         this.loadingTop);
>             }
>         }
>         else
>         {
>             this.removeStyleName(waitCursorStyle);
>             this.loadingPopup.hide();
>         }
>     }
> --------------------------------------------------------
>
> I use the following code to call it:
>
> this.showLoading(true);
> this.doStuff();
> this.showLoading(false);
>
> However, the loading box never actually shows up.  But when I do the
> following:
>
> this.showLoading(true);
> DeferredCommand.addCommand(new Command()
> {
>      public void execute()
>      {
>            parentClass.this.doStuff();
>            parentClass.this.showLoading(false);
>       }
>
> });
>
> Everything works as expected.  Does this mean that the setPopupPosition
> () and Center() methods used deferred commands?
>
> I'm at a loss as to why this happens...
>
> S
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to