Moving the reload to the onSuccess is a good suggestion.
Thanks!

On 16 apr, 18:12, Thomas Broyer <[email protected]> wrote:
> On Apr 16, 5:44 pm, Danny Goovaerts <[email protected]> wrote:
>
>
>
>
>
> > In the application that I'm building  I've implemented a
> > CloseHandler.onClose() which saves the local state in the database at
> > the server side. This state is reloaded automatically when you log on
> > the next time (fromthe same browser or from another browser, that's
> > why I am not storing it in a cookie in the client).
>
> > This all works as expected when you close the browser (or the browser
> > tab) or when you navigate to another url.
> > The application is supported in multiple languages . I switch language
> > by replacing the URL by a new URL with locale query parameter (for
> > example, the URL for the default language ishttp://www.mysite.eu/,
> > the URL for the french version ishttp://www.mysite.eu/?locale=fr).
> > This causes a reload and the application is reinitialized in the new
> > locale.
>
> > However in this case, the async call in the CloseHandler.onClose()
> > method apparently is not called or it is called, but it is cancelled.
> > I'm convinved that it is called but it is cancelled as a result of a
> > timing issue.
> > I've done the following tests:
> > * in web mode, the problem occurs
> > * in web mode, when I have emptied the browser cache, the problem does
> > not occur
> > * in hosted mode when I step through it in the debugger, the
> > CloseHandler.onClose() method is called and the RPC succeeds
> > * in hosted mode, not in the debugger, the RPC succeeds
> > * I've also tried moving the RPC call in a Window.closingHandler where
> > I set a message in the ClosingEvent. This causes a popup window. In
> > this case, the RPC call also succeeds
>
> > This leads me to the conclusion that in in Web mode, the reload
> > happens fast when the HTML page and the java script are cached, and
> > that this causes the RPCto be canceled.
>
> > What do you think?
>
> > Is there a way to prevent the RPC call from being cancelled?
>
> Using onClose to save things is unreliable and risky (you'd better
> have an explicit "save" button and in case you have unsaved changes
> ask the user to save them before "closing", using a ClosingHandler).
>
> In the case where you reload the app (with a slightly different URL),
> why not doing the RPC and do the reload in the onSuccess? (and because
> you have no unsaved changes, you don't need to save again in the
> onClose, or warn/ask the user in the ClosingHandler)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/google-web-toolkit?hl=en.

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

Reply via email to