6 Replies Latest reply: May 21, 2009 8:02 AM by Z? RSS

    How to get Current URL in Apex?

    627206
      Hi,

      Is there any Apex application variable which contain current URL , or any method so that I can get the value of URL to an application variable.

      Regards,
      Benz
        • 1. Re: How to get Current URL in Apex?
          Arie Geller
          Hello Benz,

          You can create a very simple JavaScript code to assign the current URL into a hidden page item. Something like:
          <script type="text/JavaScript">
          $s('Pxx_URL', window.location.href);
          </script>
          You can put it in the region footer, or just use the code with an ‘onload’ event.

          Regards,
          Arie.

          -------------------------------------------------------
          Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.

          Edited by: Arie Geller on May 21, 2009 10:52 AM
          • 2. Re: How to get Current URL in Apex?
            538097
            Hello,

            You can try to use together this Apex variables:
            APP_ID or FLOW_ID - current application
            FLOW_STEP_ID - current page
            SESSION - current session

            Try
            f?p=&APP_ID.:&FLOW_STEP_ID.:&SESSION.::::
            • 3. Re: How to get Current URL in Apex?
              627206
              Thanks Arie ,

              it works nicely..

              Is there anyway I can mask the URL or disable , so that user cannot nvaigate from one page to another just by chaging in page number in adrress bar.

              For eg: if current page is 2 f?p=100:2 , I should not able to goto page 3 just by chaging it to f?p=100:3 in address bar.

              Regards,
              Benz
              • 4. Re: How to get Current URL in Apex?
                Z?
                Benseer

                There are are few different ways to do this but the easiest is to enable session state protection here

                Home>Application Builder>Application XXX>Shared Components>Session State Protection

                There are downsides though, have a look in the docs.

                Cheers

                Ben
                http://www.munkyben.wordpress.com
                Don't forget to mark replies helpful or correct ;)
                • 5. Re: How to get Current URL in Apex?
                  Arie Geller
                  Hello,

                  I admit that I never really studied the Session State Protection feature, but as far as I know, only four f?p parameters are taking into account – request, clear cache, item names and item values. The target page is not assign checksum, so I’m not sure this feature can prevent deep linking all together.

                  I’m using a different approach. Usually there is a legitimate page-calling path, for every application page. For example, page 4 can only be called from the main menu, which is page 1, and page 5 can only be called from page 3. I’m using an application item called ‘caller_page’ to track the calling page. On page 4, for example, the first before header process is checking the value of the caller_page. Only if the caller_page equal 1, the user can continue; in any other case an error message is issued, with redirection to the main menu or login page.

                  Regards,
                  Arie.

                  -------------------------------------------------------
                  Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
                  • 6. Re: How to get Current URL in Apex?
                    Z?
                    Hi Arie

                    You can enable 'No URL Access' on a page level.

                    I said there are downsides - they are that this means that you can only access the page as the target of a branch - not with optional URL redirect (or from outside for that matter). It depends very much on the application as to whether this would be appropriate.

                    Cheers

                    Ben