I have a GWT application where users keep the browser based side of the application open indefinitely. Every so often we upgrade the application - if the users hit reload in their browsers after this is done then everything goes fine. However what usually happens is that they carry on using the already open version of the application, i.e. a version served before the upgrade, and then experience obscure RPC related errors as the client side Javascript is no longer in sync with what is on the server.
Does GWT have any mechanism, that you can enable or incorporate in your code, for coping with this. I don't need any clever handling of the situation, e.g. trying to reload the application and reestablish the user's current state, a simple dialog explaining that client and server are no longer in sync and that the web application needs to be reloaded would be enough.
The documentation of the interface com.google.gwt.user.client.rpc.AsyncCallback<T>
gives a hint on how to do this.
public void onFailure(Throwable caught) {
// Convenient way to find out which exception was thrown.
try {
throw caught;
} catch (IncompatibleRemoteServiceException e) {
// this client is not compatible with the server; cleanup and refresh the
// browser
} catch (InvocationException e) {
// the call didn't complete cleanly
} catch (ShapeException e) {
// one of the 'throws' from the original method
} catch (DbException e) {
// one of the 'throws' from the original method
} catch (Throwable e) {
// last resort -- a very unexpected exception
}
}
You most likely want to handle (pop-up the user dialog) the IncompatibleRemoteServiceException
.
It is called IncompatibleRemoteServiceException, and how to handle exceptions including this one is mentioned in the Google's Communicating with a Server Documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With