On Dec 2, 3:25 pm, Stephen <[email protected]> wrote:
> Hi,
>
> I'm making an async callback and in the onSuccess function I loop
> through a result set.  I would like to update a label or progressbar
> after each iteration of the loop.
>
Use the IncrementalCommand class.  In your onSuccess method, take
the loop you were writing and place it in a command:

new AsyncCallback<ArrayList<String>>() {
    public void onFailure(final Throwable t){..}
    public void onSuccess(final ArrayList<String> list) {
         final int size = list.size();
        progressBar.setCount(size);  // Defined by you.
        DeferredCommand.addCommand(new IncrementalCommand() {
             private int index = 0;
             public boolean execute() {
                 handle(list.get(index++));  // Defined by you.
                 progressBar.progress();
                 return index < size;
        }
    }
}

>
> Thanks,
> Stephen

After each element in the list is handled, the progress bar is
updated,
and the command is paused, to resume in a millisecond if there are
still
items to handle.  This also prevents the browser from thinking that
your
application is in an indefinite loop and giving the user the chance to
abort it.

Take a progress bar from any convenient source.

Respectfully,
Eric Jablow

--

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