Thank you, I understand now. I was thinking that the IncrementalCommand was the best way to allow handling click, etc... during a long processing.
2009/11/13 Thomas Broyer <[email protected]> > > > On 12 nov, 14:52, Damien Picard <[email protected]> wrote: > > Hi, > > > > I'm trying to understand the DeferredCommand.addPause function (with > > gwt-2-ms1). > > I wrote this sample : > > > > Button bouton = new Button("attente"); > > bouton.addClickHandler(new ClickHandler(){ > > @Override > > public void onClick(ClickEvent event) { > > DeferredCommand.addCommand(new Command(){ > > @Override > > public void execute() { > > GWT.log("Deferred command 1", null); > > } > > }); > > DeferredCommand.addPause(); > > DeferredCommand.addCommand(new Command(){ > > @Override > > public void execute() { > > GWT.log("Deferred command 2", null); > > } > > }); > > > > GWT.log("Event ends", null); > > } > > }); > > RootPanel.get("sendButtonContainer").add(bouton); > > > > In my mind, the pause added between the two deferred command would stop > > executing the queue until another event is handled. Then, a log like that > > should be : > > {First clic on button} > > [INFO] Event ends > > [INFO] Deferred command 1 > > {second clic and next ones} > > [INFO] Event ends > > [INFO] Deferred command 2 > > [INFO] Deferred command 1 > > > > but I get this log : > > [INFO] Event ends > > [INFO] Deferred command 1 > > [INFO] Deferred command 2 > > > > So, I haven't understand exactly what is a pause. Could somebody explain > me > > where I'm wrong ? > > addPause semantics actually is "let the browser do its things (such as > refreshing the display or handling events)". > > DeferredCommand's are batched together and executed in a single run, > until the next "pause". > If a run of commands takes long enough so that you can "generate > events" (e.g. click), then those click events are likely to be > processed during the "pause": try doing some expensive work in the > first deferred command (such as creating and appending 1000 DOM > elements to the document; you can try also with a Window.alert()) and > generate a second click event during this time (before dismissing the > alert, if you shows Window.alert) and you should see: > [INFO] Event ends > [INFO] Deferred command 1 > [INFO] Event ends > [INFO] Deferred command 2 > [INFO] Deferred command 1 > [INFO] Deferred command 2 > Similarly, if you update the display (e.g. show/hide widgets or text), > it'll only be refreshed on screen during the "pause": try showing/ > hiding a widget in the first command and then show an alert > (Window.alert), and show an alert in the second command, you log > should be (annotated): > [INFO] Event ends > [INFO] Deferred command 1 > // alert, notice that the display hasn't changed > [INFO] Deferred command 2 > // alert, and now the display has changed > > -- > > 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]<google-web-toolkit%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=. > > > -- Damien Picard Open Source BPM : http://code.google.com/p/osbpm -- 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=.
