Saturday, May 2, 2015

Synchronized code after a service call


Hi,

I am new in using GWT.

I make a call to a remote service from within a for loop and update a FlexTable in a DialogBox.
After finishing the loop, I would like to add extra row to the table with two button.
Here is how the code structure looks like:

initDialogBox(); // instantiate a dialogbox and set the caption and add a FlexTable  

for (final String str : strList) {
   configurationsService.testStr(str,
        new AsyncCallback<Boolean>() {
        @Override
        public void onSuccess(Boolean result) {
             updateDialogBox(db, result);  // get the FlextTable and add a row to it with db and result as columns
        }

       @Override
        public void onFailure(Throwable caught) {
              // some code           
        }
    });
}
finalizeDialogBox(); // add two button to the last row of the table


The problem is it seems finalizeDialogBox() runs before service call finishes and table
appears with two buttons at the first row.

Any idea how to fix this?

Thanks,
Cheers,
Alireza

--
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/d/optout.

No comments:

Post a Comment