2 Replies Latest reply: Mar 6, 2013 5:38 AM by Joel_C RSS

    apex_util.prepare_url

    Spooky
      Hi!

      I am using
      htp.p('<a href = "link"  >title</a>'); 
      in PL/SQL region to make dynamic links to pages in my app.
      How can I write apex URL into href tag to just go on apllication page, let's say 21?

      I tried with apex_util.prepare_url:
       htp.p('<a hrefff = "' || apex_util.prepare_url('f?p=&APP_ID.:21:&APP_SESSION.::::') ||'">link name</a>');
      But it generates "f?p=0:12::::::" link
        • 1. Re: apex_util.prepare_url
          scott.wesley
          Bind variables should always be first preference for substitution
          htp.p('<a hrefxx="' || apex_util.prepare_url('f?p='||:APP_ID||':21:'||:APP_SESSION||'::'||:DEBUG||'::') ||'">link name</a>');
          • 2. Re: apex_util.prepare_url
            Joel_C
            Spooky wrote:
            Hi!

            I am using
            htp.p('<a href = "link"  >title</a>'); 
            in PL/SQL region to make dynamic links to pages in my app.
            How can I write apex URL into href tag to just go on apllication page, let's say 21?

            I tried with apex_util.prepare_url:
            htp.p('<a hrefff = "' || apex_util.prepare_url('f?p=&APP_ID.:21:&APP_SESSION.::::') ||'">link name</a>');
            But it generates "f?p=0:12::::::" link
            That is the expected behaviour. Have a look at the examples in the documentation - note the description for the main "p_url" parameter (bold is my emphasis):
            >
            p_url An f?p relative URL with all substitutions resolved
            >

            This means you have to substitute the values in the code itself, rather than passing references (if you want to use prepare_url, that is).