Sunday, January 30, 2011

Re: how to handle cases where a user Repeatedly presses browser Refresh button in the middle of server call ?

There are 2 strategies (that can be combined):
  • track ongoing async calls, listen to Window.ClosingEvent and ask (ClosingEvent#setMessage) the user if he really wants to leave (you can't tell refreshes from window/tab closing from other kind of navigations), in case there are ongoing requests
  • some browsers (Firefox, maybe Chrome and Safari too) abort ongoing requests with a "0" status code when you navigate away (or otherwise "unload" the page: refresh the page, close the tab or window). You can special-case that status code and simply do nothing in this case (no need to update the page, even with an error message, as it will be unloaded anyway)
Note that you don't have to repeatedly refresh to page to trigger that behavior; anything that "unloads" the page while there's an ongoing request will do.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment