-
1. Re: How to replace the class in Errai for ResponseException
csa Jan 6, 2014 11:57 AM (in response to shut_desert)Hi,
replace-with in your gwt.xml defines a GWT rebind rule for deferred binding. We don't use deferred binding when creating instances of transport handlers. So, you cannot use this mechanism to override the behaviour in HttpPollingHandler. Also, Errai's message bus will use different transport handlers based on the capabilities of your browser and server. So, even if you could override HttpPollingHandler this wouldn't be a reliable solution.
Can you elaborate why you want to do this? It sounds like switching to a plain REST based communication with Errai JAX-RS is a better solution in this case.
Christian
-
2. Re: Re: How to replace the class in Errai for ResponseException
shut_desert Jan 6, 2014 12:49 PM (in response to csa)We are developing an application where all the services are working only through RPC. When I call the service, I have to check the status code of the response. Then I have to handle this status code. For example, if the status is 401, I have to redirect to the login page. I used the Interceptor for service so, but nothing happens:
public class SimpleInterceptor implements RpcInterceptor { @Override public void aroundInvoke(final RemoteCallContext context) { final RemoteCallback remoteCallback = new RemoteCallback() { @Override public void callback(Object response) { context.setResult(response); } }; final ErrorCallback errorCallback = new ErrorCallback() { @Override public boolean error(Object message, Throwable throwable) { try { throw throwable; } catch (ResponseException responseException) { int statusCode = responseException.getResponse().getStatusCode(); if (statusCode == 401) { Window.Location.assign("/login.jsp"); } } catch (Throwable t) { t.printStackTrace(); } return false; } }; context.proceed(remoteCallback, errorCallback); } }
Why would I want to replace the class HttpPollingHandler? I wanted to add my implementation to handle the different status code. How can I do this? Maybe do this through the GWT? Help solve this problem...