Monday, May 31, 2010

Re: How can I prevent from reloading the page when the reload button on browser is clicked?

It is not possible to avoid refresh(reload) through scripts. The only
possible thing is you could display an alert message through the
browser which provides the User with option to either stay on the page
or leave it. Which is what is done in the CloseHandler in your example
script.

What federico wants to say is you should use history-tokens to save
your states.

Use Refresh, Back, Forward as a feature and not a catastrophe, with
the the help of GWT History support.

On Jun 1, 6:57 am, Mike Jiang <mikej1...@gmail.com> wrote:
> Don't get it. Please show your good design in an understandable style.
>
> On Fri, May 28, 2010 at 4:49 PM, federico <federico.mona...@gmail.com>wrote:
>
>
>
> > bad design.
> > "refresh" is a feature and you should provide bokmarkable refresh-save
> > pages.
>
> > On 28 Mag, 20:42, Mike J <mikej1...@gmail.com> wrote:
> > > Hi,
> > >    I ran into a problem about clicking the "reload" button on a web
> > > browser.
>
> > >    My app is a stateful GWT app. Users need to be authenticated for
> > > login. After login they can surf on various pages. But users sometimes
> > > were used to press the "reload" button on the browser to refresh the
> > > page.
>
> > >    The reloading process just bring the screen back to a reboot state,
> > > with all state info lost. That's not what we expect.
>
> > >    The quick solution is, catch the reload event before the browser
> > > sends the "reload" request to the web server and prevent the browser
> > > from sending it.
>
> > >    I have read the relevant posts in this group and found the useful
> > > info that "reload" event is equivalent to the Window Closing event. So
> > > in the following code snippet I can catch the event,
>
> > >    Window.addCloseHandler(new CloseHandler<Window>() {
> > >             public void onClose(CloseEvent<Window> event) {
> > >                 //prevent browser sending the reload request to the
> > > web browser
> > >             }
> > >         });
>
> > >    But I don't know how I can stop the browser from sending the
> > > "reload" request to the web server.
>
> > >    Thanks for any help,
>
> > >    Mike J.
>
> > --
> > 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<google-web-toolkit%2Bunsubs cribe@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://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 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