Hi guys,
I have the following data source:
This data source is added to a list grid. A reload is triggered by some external event. A new reload can be triggered before the RPC service returns from server and the roc request will be cancelled. I use this pattern in other contexts, but when I do the same inside a data source, I do not get a response back to the list grid with data.
If the RPC service finishes, the list grid is updated correctly. But if at any time, a new reload cancels the previous request, then the list grid does not get updated with data and is just showing the loading message. Any subsequent reloads does not update the listgrid - even though processResponse is called (processResponse is called every time).
Are there any issues with cancelling a RPC request inside a data source - or am I missing something here?
Best Regards
Rasmus
I have the following data source:
Code:
public class MyDS extends DataSource { private com.google.gwt.http.client.Request currentRequest; public MyDS() { setID("ds_" + new Date().getTime()); setDataFormat(DSDataFormat.CUSTOM); setDataProtocol(DSProtocol.CLIENTCUSTOM); setClientOnly(true); } @protected Object transformRequest(DSRequest req) { if(currentRequest != null) { currentRequest.cancel(); } // someMethod might take a long time, example: 10-20 seconds currentRequest = myRpcService.someMethod(new AsyncCallback<Void>() { public void onSuccess(Void result) { currentRequest = null; // ... create response etc. DSReponse response = new DSResponse(); response.setStatus(DSResponse.STATUS_SUCCESS); response.setData(... some data ...); super.processResponse(req.getRequestId(), response); } public void onFailure() {} }); } } public class MyListGrid extends ListGrid { public MyListGrid() { super(); setFields(createFields()); setDataSource(new MyDS()); setDataFetchMode(FetchMode.LOCAL); } public void reload() { invalidateCache(); fetchData(); } }
If the RPC service finishes, the list grid is updated correctly. But if at any time, a new reload cancels the previous request, then the list grid does not get updated with data and is just showing the loading message. Any subsequent reloads does not update the listgrid - even though processResponse is called (processResponse is called every time).
Are there any issues with cancelling a RPC request inside a data source - or am I missing something here?
Best Regards
Rasmus
Comment