ajaxgwtrpcgwt-rpcgquery

GWT RPC - Parallel asynchronous calls


I have a list of promises that needs to be executed in parallel and in an asynchronous manner.Say,i have,

List<Promise<X>> list;    

Once all the parallel request completes, i need to make another request say "Y". Here is my GWT code,

GQuery.when(list).done(...).fail(..)

But the above doesn seem to work!.How can i pass a list of promises to GQuery?.Is the above synctax valid?.


Solution

  • If you create a sample GWT project in Eclipse, a simple asynchronous RPC call is created. You can take that as a template to change it the way you need. With the callback of the request is it possible to display your "Y".

    // Set up the callback object.
    AsyncCallback<List<Promise<X>>> callback = new AsyncCallback<List<Promise<X>>>() {
        public void onFailure(Throwable caught) {
            // TODO: Do something with errors.
        }
    
        public void onSuccess(List<Promise<X>> result) {
            // TODO: DO something with the result.
        }
    };
    

    You should also read the documentations, at least... http://www.gwtproject.org/doc/latest/tutorial/RPC.html