I am using GWT and RPC in my app. after session expires when I do a RPC call, because of my login-filter the request redirect to login.jsp, but my problem is client doen’t show me login.jsp instead the RPC’s onFailure raised.
It means I should handle all my rpc’s onFailure events for redirecting to login page ?!!!!
Thanks
I agree with pathed that you should do redirecting in your
AsyncCallbacks. However, you don’t need to explicitly use your customMyAsyncCallbackcallbacks instead of standard GWTAsyncCallback. This is important for example when you already have a lot of code that uses standard callbacks.When you invoke
GWT.create(MyService.class)GWT generates proxy for yourMyServiceAsyncservice interface. This proxy is responsible for communicating with the server and invoking your callbacks when it gets data from the server. Proxies are generated using GWT code generators mechanism and by default GWT usesServiceInterfaceProxyGeneratorclass to generate these proxies.You can extend this default generator (
ServiceInterfaceProxyGeneratorclass) to automatically use your custom MyAsyncCallbacks in all callbacks invocations. We recently did exactly that in a project. Below there is source code which we used.Code for
MyAsyncCallback, it is identical to the one presented by pathed:Code for GWT code generator (
MyRpcRemoteProxyGenerator):And generator helper class (
MyProxyCreator):Finally you need to register the new code generator to be used for generating proxies for async services. This is done by adding this to your GWT configuration file (gwt.xml file):
At the beginning it may seem to be a very complicated solution 🙂 but it has its strengths:
AsyncCallbacksgenerate-within your GWT config files)