This discussion is archived
10 Replies Latest reply: Jan 21, 2013 4:58 PM by ruramach - oracle RSS

Navigating back to calling page

VANJ Journeyer
Currently Being Moderated
Many times, there is a drilldown/detail page that can be navigated to from many different pages in the application and there is a need to provide a "BACK" button on the page to go back to the calling page.

If the navigation is done using links/lists/column links, etc, I use the following technique to implement this.

1. Create a application level item CALLING_PAGE
2. Create a Before Header application computation for CALLING_PAGE of type Function body to set to
declare
l_referer varchar2(500) := owa_util.get_cgi_env('HTTP_REFERER');
begin
  return substr(l_referer,instr(l_referer,':',1,2)+1,instr(l_referer,':',1,3)-instr(l_referer,':',1,2)-1);
end;
3. Now, simply set up a BACK Button on that common page with a URL redirect of
&CALLING_PAGE.
and that will take you back to the calling page.

Basically, it just parses out the page# from the f?p= URL in the HTTP_REFERER CGI variable.

Hope this helps.
  • 1. Re: Navigating back to calling page
    453354 Newbie
    Currently Being Moderated
    Very useful - will definetly make use of this Vikas :)
  • 2. Re: Navigating back to calling page
    431216 Newbie
    Currently Being Moderated
    Beware the following from RFC 2616 "Hypertext Transfer Protocol -- HTTP/1.1":

    "Because the source of a link might be private information or might reveal an otherwise private information source, it is strongly recommended that the user be able to select whether or not the Referer field is sent."

    Some people, browsers, firewalls, and proxies choose not to send the Referer field, leading to a blank HTTP_REFERER.

    One can accomplish the same effect by setting the application item in the branch leading to the page. It's a hassle, but it avoids a dependence on a browser feature that is not guaranteed to be there.

    Rodney
  • 3. Re: Navigating back to calling page
    VANJ Journeyer
    Currently Being Moderated
    branch leading to the page

    Thanks for the clarification but as I said earlier this is when "the navigation is done using links/lists/column links". In these cases, there is no branch, the page is navigated to using a link and the calling page information is available only in that Referer field (I think, feel free to correct me if I am wrong).

    Thanks.
  • 4. Re: Navigating back to calling page
    431216 Newbie
    Currently Being Moderated
    For cases where you know what page you are on (e.g., a column link on a report on a particular page), you can hardcode the current page number into the link or URL if you prefer simple and direct. In other cases or when you prefer generality, you can use APP_PAGE_ID.

    Rodney
  • 5. Re: Navigating back to calling page
    VANJ Journeyer
    Currently Being Moderated
    Yes, I realize that and was merely offering an alternative "automated" method that would obviate the need to "remember" to stick in P1_CALLING_PAGE:&APP_PAGE_ID. every time you link to Page 1. In other words, every page that is navigated to using a link, no matter from whereever in the app, would automatically "know" which page "called" it and be able to provide a Back button (if needed) to navigate back to that page.

    Your caveat about users (or browsers, proxies or other components) intentionally turning off the HTTP_REFERER is a valid point and clearly that makes my proposed technique not work, thanks for pointing that out.
  • 6. Re: Navigating back to calling page
    431216 Newbie
    Currently Being Moderated
    I certainly understand your point about it being easy to forget to include the back reference and agree that your method avoids that.

    I also didn't mean to say that one should never use HTTP_REFERER--just that it should be done with an awareness of the risks. The truth is that 100% conformance to standards does not necessarily get you an application that everyone can use.

    Maybe Oracle could add an APP_PREV_PAGE_ID variable. :-)

    Rodney
  • 7. Re: Navigating back to calling page
    478676 Journeyer
    Currently Being Moderated
    Nice trick, very handy.
    Thanks

    Paulo
  • 8. Re: Navigating back to calling page
    48266 Newbie
    Currently Being Moderated
    Hi Vikas,

    Thanks for the neat trick.

    However, to get it to work we eliminated the INSTR and SUBSTR code. Using the INSTR and SUBSTR code resulted in a corrupted URL.

    We changed the PL/SQL code to:

    declare l_referer varchar2(500) := owa_util.get_cgi_env('HTTP_REFERER');
    begin
    return l_referer ;
    end;

    We are using IE 6.0 and APEX 2.0.

    Does anyone have any insight as to why the difference?

    Cheers,
    Patrick
  • 9. Re: Navigating back to calling page
    VANJ Journeyer
    Currently Being Moderated
    My initial post with all that INSTR/SUBSTR showed how to extract just the page# part from the f?p= URL. If you would like to use the entire URL returned by the CGI variable HTTP_REFERER, that is fine too.
  • 10. Re: Navigating back to calling page
    ruramach - oracle Newbie
    Currently Being Moderated
    Hi Vikasa,

    Quite useful trick. One thing I noticed was that if the referer url has a port number, the first colon in the referer url will be used to seperate the port number from the server name and the string manipulation will break. Had to modify it to the following to get it to work:

    declare
    l_referer varchar2(500) := owa_util.get_cgi_env('HTTP_REFERER');
    l_referer_query_string varchar2(500);
    begin
    l_referer_query_string := substr(l_referer,instr(l_referer,'?') + 1);
    return SUBSTR(l_referer_query_string, INSTR(l_referer_query_string, ':', 1, 1) + 1, INSTR(l_referer_query_string, ':', 1, 1 + 1) - INSTR(l_referer_query_string, ':', 1, 1) - 1);
    end;

    Regards,
    Rupesh