This discussion is archived
2 Replies Latest reply: Nov 12, 2013 10:23 PM by DilipG RSS

How to get handle browser back button…

Harrrry Newbie
Currently Being Moderated

Hi All,

 

We have a requirement, if user clicks on browser back button we need to throw an error message. used the below code.. but no use…

In PR:

 

Option1:

        if (pageContext.isBackNavigationFired(true)) {

            pageContext.writeDiagnostics(this, "@@Hari Back button pressed In PR ", 1);

            throw new OAException("Do not press back button..");

        }

 

 

Option2:

 

       OABodyBean bodyBean = (OABodyBean) pageContext.getRootWebBean();

        String javaS = "javascript:window.history.forward(1);";

        bodyBean.setOnLoad(javaS);

 

Can you please help me out

 

Regards

--Harry

  • 1. Re: How to get handle browser back button…
    Harrrry Newbie
    Currently Being Moderated

    How do i use the below code in OAF process request:

     

    <SCRIPT type="text/javascript">

        window.history.forward();

        function noBack() { window.history.forward(); }

    </SCRIPT>

    </HEAD>

    <BODY onload="noBack();"

        onpageshow="if (event.persisted) noBack();" onunload="">

     

    Thanks

    --Harry

  • 2. Re: How to get handle browser back button…
    DilipG Journeyer
    Currently Being Moderated

    Hi Harry,

     

    Try Below code in Controller PR

     

    //In PR of Controller

    public void processRequest(OAPageContext pageContext, OAWebBean webBean)

    {

    ...

    // Display a standard error message related to state loss due to Back button

    // navigation or failover as appropriate.

    if (pageContext.isBackNavigationFired(true))

    {

    pageContext.redirectToDialogPage(new OADialogPage(NAVIGATION_ERROR));

    }

    else

    {

    pageContext.redirectToDialogPage(new OADialogPage(FAILOVER_STATE_LOSS_ERROR));

    }

    }

     

    Thanks,

    Dilip

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points