You should be able to throw your exception from anywhere on the server side
and have it appear on the client side's onFailure (if the exception
implements IsSerializable).

--
Arthur Kalmenson


On Fri, Dec 19, 2008 at 1:10 PM, deanhiller <dean.hil...@gmail.com> wrote:

>
> How does that work?  I am doing the above code in a servlet filter so
> there is no GWT code above the filter.  All the GWT code is in the
> RemoteServlet and ServletFilters run before the RemoteServlet code
> does.  I also want to throw a GwtSessionTimeoutException so I can pass
> a url for the gwt clients to redirect to the correct location.  I have
> many GWT apps that will use this filter.
> thanks,
> Dean
>
> On Dec 18, 7:06 am, "Arthur Kalmenson" <arthur.k...@gmail.com> wrote:
> > Hi Dean,
> >
> > Are you trying to encode an exception to throw it back to the client
> > side? AFAIK, you can just throw a IsSerializable exception in your
> > code and GWT-RPC will transfer the said exception to the client side
> > for you.
> >
> > --
> > Arthur Kalmenson
> >
> > On Thu, Dec 18, 2008 at 12:55 AM, deanhiller <dean.hil...@gmail.com>
> wrote:
> >
> > > I have the following code in a servlet filter....
> >
> > >                GwtSessionTimeout timeout = new GwtSessionTimeout(
> > >                                "Session timed out.  You need to
> redirect to the url in getUrl
> > > function",
> > >                                url);
> > >                try {
> > >                        String payload =
> RPCServletUtils.readContentAsUtf8(request, true);
> > >                        RPCRequest rpcRequest =
> RPC.decodeRequest(payload);
> > >                        payload = RPC.encodeResponseForFailure(null,
> timeout);
> >
> > >                        boolean gzipEncode =
> RPCServletUtils.acceptsGzipEncoding(request)
> > >                                        &&
> shouldCompressResponse(request, response, payload);
> >
> > >                        ServletContext servletContext =
> request.getSession
> > > ().getServletContext();
> > >                        RPCServletUtils.writeResponse(servletContext,
> response, payload,
> > > gzipEncode);
> >
> > >                } catch (SerializationException e) {
> > >                        throw new RuntimeException("Exception", e);
> > >                } catch (ServletException e) {
> > >                        throw new RuntimeException("Exception",e);
> > >                }
> >
> > > The browser(firefox) says "This application is out of date, please
> > > click the refresh button on your browser."
> >
> > > If I change
> > > payload = RPC.encodeResponseForFailure(null, timeout);
> > > to
> > > payload = RPC.encodeResponseForFailure(rpcRequest.getMethod, timeout);
> >
> > > it fails with UnexpectedException like GwtSessionTimeout was not a
> > > RuntimeException, but it is a RuntimeException so it should work and I
> > > expect the aysncCallback.onFailure to be called, but it doesn't work.
> >
> > > Here is my GwtSessionTimeout....
> > > public class GwtSessionTimeout extends RuntimeException implements
> > > IsSerializable{
> > > }
> >
> > > why isn't this working?
> > > later,
> > > Dean
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to