Search code examples
gwtgwt-rpc

How to make wait some time in GWT after the Async call


In my code, I am making async call to do validation. Depeding upon return value of the validation, I need to execute some lines. But I am not able to put that lines in the callback method of Async = public void success(Boolean valid).

Since one of the line is super.onDrop(context) which is method of another class that can't be called inside Async callback method.

Please see the below line. I need super.onDrop(context) will be executed after async call is completed.

stepTypeFactory.onDropValidation(stepTypeFactory,new AsyncCallbackModal(null) { public void success(Boolean valid) { if(valid==Boolean.TRUE){ //super.onDrop(context); } }; });

//condition is here super.onDrop(context);

Is there any way, i will tell gwt wait 1 or 2 seconds before super.onDrop(context) is executed. Right now what happening is, super.onDrop(context) is executed before the call back method is completed.


Solution

  • You can do:

    stepTypeFactory.onDropValidation(stepTypeFactory,new AsyncCallbackModal(null) {
        public void success(Boolean valid) {
            if(valid==Boolean.TRUE){
                drop();
            }
        };
    });
    
    private void drop() {
       super.onDrop(context);
    }