Window.confirm/alert is pretty much the only thing that can halt Javascript execution.
You have to refactor your code a bit. Instead of
public boolean doPost(String url, String postData)
you should use
public void doPost(String url, String postData, Callback<..., ...> callback) {
dlg.show();
builder.sendRequest(postData, new RequestCallback() {
void onError(....) {
dlg.hide();
callback.onFailure(...);
}
void onResponseReceived(...) {
dlg.hide();
if(statusCode == OK) {
callback.onSuccess(...);
} else {
callback.onFailure(...);
}
}
});
}
So everyone who calls your doPost() method has to provide a callback in order to be notified when the post succeeds or fails. You have to think asynchronous :-) The only thing that makes sense to return in that case is the Request instance created by builder.sendRequest(...), so the calling code can cancel the request if needed:
public Request doPost(..., Callback callback) {
dlg.show();
return builder.sendRequest(...);
}
-- J.