Geo*_*ins 5 browser gwt webserver asynchronous gwt-rpc
我有一个GWT应用程序,用户可以无限期地打开应用程序的浏览器端.我们经常升级应用程序 - 如果用户在完成此操作后在浏览器中重新加载,那么一切都会顺利进行.然而,通常会发生的是,他们继续使用已经打开的应用程序版本,即升级之前提供的版本,然后遇到模糊的RPC相关错误,因为客户端Javascript不再与服务器上的内容同步.
GWT是否有任何机制,您可以启用或合并到您的代码中,以应对此问题.我不需要任何巧妙处理的情况,例如尝试重新加载应用程序并重新建立用户的当前状态,一个简单的对话框解释客户端和服务器不再同步并且Web应用程序需要重新加载就足够了.
接口的文档com.google.gwt.user.client.rpc.AsyncCallback<T>给出了如何执行此操作的提示。
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
}
}
Run Code Online (Sandbox Code Playgroud)
您很可能想要处理(弹出用户对话框)IncompatibleRemoteServiceException.
| 归档时间: |
|
| 查看次数: |
539 次 |
| 最近记录: |