• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to call Action class when back button is clicked ?

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need to give a call to my action class in case the browser back button is clicked.

Can i have the solution for the same ?

Thanks in advance
Mickey Smith
 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe that some of the Javascript framework libraries provide a way to capture the browser back button -- dojo toolkit comes to mind. I know that dojo allows capturing back clicks as part of their dojo.io.bind class, That may be something you can extract from their source code and re-use for your purposes.

Basically you would have to capture the back button, send a message to the server (your call to the action class), and then let the browser process the back button request. This usually just results in the previous page in history being loaded from cache, which is why the server doesn't know that the back button was used.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no action fired for the back button.

Eric
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have written a Filter that will add to the response's header so that in theory none of our pages should be cached by any server or browswer. Therefore when a browsers back button is pressed a new request is sent to the server for the page.

 
Philip Shanks
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Eric Pascarello:
There is no action fired for the back button.

Eric



True, there is no direct Javascript hook for this (should there be? I imagine it would be heavily abused), but I believe that the dojo packages are using iframe navigation to provide a logical hook. I think this is why their mechanism doesn't work in Safari.

On the other hand, wouldn't the onunload event get fired as a result of a back-button click? Perhaps this could somehow be leveraged to alert the application that the back button *may* have been used. I don't know how this could be made either efficient or effective.
[ February 09, 2007: Message edited by: Philip Shanks ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic