FAQ
Hi

Is there any way I can detect if the user clicked the browser's back button? I need to take some action when user clicks the browser's back button.

TIA
-Srikanth Madarapu

Search Discussions

  • Mike Kienenberger at May 6, 2005 at 9:20 pm
    I haven't done this yet, but I believe you'd handle back button issues
    with a custom StateManager.:

    http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/javax/faces/application/StateManager.html

    On 5/6/05, Srikanth Madarapu wrote:
    Hi

    Is there any way I can detect if the user clicked the browser's back button? I need to take some action when user clicks the browser's back button.

    TIA
    -Srikanth Madarapu
  • Srikanth Madarapu at May 9, 2005 at 1:11 pm
    Thanks for the information, do you know any more details, like at what point I can trap the back button event using the state manager? Is there a request generated when the back button is pressed ?

    Thanks
    Srikanth

    -----Original Message-----
    From: Mike Kienenberger
    Sent: Friday, May 06, 2005 5:21 PM
    To: MyFaces Discussion
    Subject: Re: detecting back button


    I haven't done this yet, but I believe you'd handle back button issues
    with a custom StateManager.:

    http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/javax/faces/application/StateManager.html

    On 5/6/05, Srikanth Madarapu wrote:
    Hi

    Is there any way I can detect if the user clicked the browser's back button? I need to take some action when user clicks the browser's back button.

    TIA
    -Srikanth Madarapu
  • Srikanth Madarapu at May 9, 2005 at 2:03 pm
    Hi

    I have found a place where I could find if the user used the browser's navigation buttons. The "getSerializedViewFromServletSession" method of "JspStateManagerImpl" class knows the currentViewId and the savedViewId, if they are different user must have pressed the back or forward buttons of the browser. ( I am using myfaces 1.0.7).

    But I still cannot tell if the user has pressed the back or forward button. I need to perform some action if the user pressed the back button. Is there any way to find that out ?

    Any input is of great help, thanks in advance.

    Srikanth


    -----Original Message-----
    From: Srikanth Madarapu
    Sent: Monday, May 09, 2005 9:07 AM
    To: MyFaces Discussion; Mike Kienenberger
    Subject: RE: detecting back button


    Thanks for the information, do you know any more details, like at what point I can trap the back button event using the state manager? Is there a request generated when the back button is pressed ?

    Thanks
    Srikanth

    -----Original Message-----
    From: Mike Kienenberger
    Sent: Friday, May 06, 2005 5:21 PM
    To: MyFaces Discussion
    Subject: Re: detecting back button


    I haven't done this yet, but I believe you'd handle back button issues
    with a custom StateManager.:

    http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/javax/faces/application/StateManager.html

    On 5/6/05, Srikanth Madarapu wrote:
    Hi

    Is there any way I can detect if the user clicked the browser's back button? I need to take some action when user clicks the browser's back button.

    TIA
    -Srikanth Madarapu
  • Matt Blum at May 9, 2005 at 2:55 pm
    I can't think of an elegant way to do what you want, but here's an inelegant
    way:

    Add logic to your application to add a counting parameter to the query
    string of every URL (including those for form submission), so that every URL
    looks something like this:

    http://yourserver/foo.jsf?pageCount=24&x=2&y=5

    The parameter would be incremented by a filter, which would store a counter
    in the session and check the URL that's coming in. If the URL's counter
    matches the count currently stored in the session when the filter fires,
    everything's fine and the filter need only increment the counter in the
    session so it can be used to create new URLs. If the URL's counter doesn't
    match, you should be able to easily tell what the user did to make that
    happen and take some action.

    Obviously, making sure all URLs are thusly modified is a pain, but it's the
    only way I can think of to do what you want to do, off the top of my head.

    -Matt
    On 5/9/05, Srikanth Madarapu wrote:

    Hi

    I have found a place where I could find if the user used the browser's
    navigation buttons. The "getSerializedViewFromServletSession" method of
    "JspStateManagerImpl" class knows the currentViewId and the savedViewId, if
    they are different user must have pressed the back or forward buttons of the
    browser. ( I am using myfaces 1.0.7).

    But I still cannot tell if the user has pressed the back or forward
    button. I need to perform some action if the user pressed the back button.
    Is there any way to find that out ?

    Any input is of great help, thanks in advance.

    Srikanth


    -----Original Message-----
    From: Srikanth Madarapu
    Sent: Monday, May 09, 2005 9:07 AM
    To: MyFaces Discussion; Mike Kienenberger
    Subject: RE: detecting back button

    Thanks for the information, do you know any more details, like at what
    point I can trap the back button event using the state manager? Is there a
    request generated when the back button is pressed ?

    Thanks
    Srikanth

    -----Original Message-----
    From: Mike Kienenberger
    Sent: Friday, May 06, 2005 5:21 PM
    To: MyFaces Discussion
    Subject: Re: detecting back button

    I haven't done this yet, but I believe you'd handle back button issues
    with a custom StateManager.:


    http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/javax/faces/application/StateManager.html
    On 5/6/05, Srikanth Madarapu wrote:
    Hi

    Is there any way I can detect if the user clicked the browser's back
    button? I need to take some action when user clicks the browser's back
    button.
    TIA
    -Srikanth Madarapu
  • Gvanmatre at May 9, 2005 at 3:48 pm
    You might check out the Token component in Shale.

    http://people.apache.org/~craigmcc/shale-core-javadocs/org/apache/shale/component/Token.html

    It is kind of similar to the synchronization token is Struts.
  • Sean Schofield at May 9, 2005 at 5:00 pm
    I agree. <s:token> in Shale is really sweet. Its a nice example of
    how you can do something simply and elegantly in JSF.

    sean
    On 5/9/05, gvanmatre@comcast.net wrote:
    You might check out the Token component in Shale.

    http://people.apache.org/~craigmcc/shale-core-javadocs/org/apache/shale/component/Token.html

    It is kind of similar to the synchronization token is Struts.



    ---------- Forwarded message ----------
    From: Matt Blum <mblum42@gmail.com>
    To: MyFaces Discussion <users@myfaces.apache.org>
    Date: Mon, 9 May 2005 14:55:08 +0000
    Subject: Re: detecting back button
    I can't think of an elegant way to do what you want, but here's an inelegant way:

    Add logic to your application to add a counting parameter to the query string of every URL (including those for form submission), so that every URL looks something like this:

    http://yourserver/foo.jsf?pageCount=24&x=2&y=5

    The parameter would be incremented by a filter, which would store a counter in the session and check the URL that's coming in. If the URL's counter matches the count currently stored in the session when the filter fires, everything's fine and the filter need only increment the counter in the session so it can be used to create new URLs. If the URL's counter doesn't match, you should be able to easily tell what the user did to make that happen and take some action.

    Obviously, making sure all URLs are thusly modified is a pain, but it's the only way I can think of to do what you want to do, off the top of my head.

    -Matt
    On 5/9/05, Srikanth Madarapu wrote:
    Hi

    I have found a place where I could find if the user used the browser's navigation buttons. The "getSerializedViewFromServletSession" method of "JspStateManagerImpl" class knows the currentViewId and the savedViewId, if they are different user must have pressed the back or forward buttons of the browser. ( I am using myfaces 1.0.7).

    But I still cannot tell if the user has pressed the back or forward button. I need to perform some action if the user pressed the back button. Is there any way to find that out ?

    Any input is of great help, thanks in advance.

    Srikanth


    -----Original Message-----
    From: Srikanth Madarapu
    Sent: Monday, May 09, 2005 9:07 AM
    To: MyFaces Discussion; Mike Kienenberger
    Subject: RE: detecting back button

    Thanks for the information, do you know any more details, like at what point I can trap the back button event using the state manager? Is there a request generated when the back button is pressed ?

    Thanks
    Srikanth

    -----Original Message-----
    From: Mike Kienenberger
    Sent: Friday, May 06, 2005 5:21 PM
    To: MyFaces Discussion
    Subject: Re: detecting back button

    I haven't done this yet, but I believe you'd handle back button issues
    with a custom StateManager.:

    http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/javax/faces/application/StateManager.html
    On 5/6/05, Srikanth Madarapu wrote:
    Hi

    Is there any way I can detect if the user clicked the browser's back button? I need to take some action when user clicks the browser's back button.

    TIA
    -Srikanth Madarapu

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriesmyfaces
postedMay 6, '05 at 8:36p
activeMay 9, '05 at 5:00p
posts7
users5
websitemyfaces.apache.org

People

Translate

site design / logo © 2019 Grokbase