I want to break the for loop in GWT callback's execute method response.
For Example,
for (int idx = 0; idx < recordList.getLength(); idx++) { //Starting ABC FOR LOOP
ABCDMI.addData(recordList.get(idx),
new DSCallback() {
public void execute(DSResponse response, Object rawData, DSRequest request) {
if(response.getAttribute("UnSuccess") != null && !response.getAttribute("UnSuccess").equalsIgnoreCase("")) {
break; //I want to break ABC FOR LOOP here.
}
}
}
Can anybody help me in this?
When you call an asynchronous method, you dont know how long it will take. In your examples all of these calls will be sent in almost the same instant, but the response would come in any time in the future, so the order is not guaranteed.
Of-course you cannot break a loop inside your callback, but you can handle the loop inside your callback calling the async method from it each time one call finishes.
This example should work in your case, and all callbacks would be executed sequentially.