here is how my onSuccess function looks, in this example I'm simply
wanting to update a label's text during each loop iteration.  How
would this look like using the incremental command class?  Would
everything here go inside the incrementalcommand? Thanks!

public void onSuccess(MarkerDataSet<MarkerData> markerData) {
                                if (markerData != null) {
                                        String numMarkers = 
Integer.toString(markerData.size());
                                        int counter = 0;
                                        lblProgress.setText("0 out of " + 
numMarkers);
                                        
pathset.getMapWrapper().setAllMarkers(markerData);
                                        for (Iterator<MarkerData> iter = 
markerData.iterator();
iter.hasNext();) {
                                                counter++;
                                                
lblProgress.setText(Integer.toString(counter) + " out of " +
numMarkers); // this is the label I want to update
                                                MarkerData data = iter.next();
                                                genericMarker.add(new 
SoundMarker(pathset.getMap(),data, true));

                                        }
                                }

                        }




On Dec 2, 4:30 pm, Eric <[email protected]> wrote:
> 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