如何在 APEX_UTIL.PREPARE_URL 中包含会话 ID?

发布于 2025-01-12 21:18:07 字数 2201 浏览 0 评论 0原文

我正在运行 Apex 20.1,我需要生成一些包含校验和和会话的 URL(这是强制性的)。

我正在做 :

Output := APEX_UTIL.PREPARE_URL(p_url => 'f?p=' || ApplicationAlias || ':' || PageAlias || ':' || SessionId ||'::::' || Arguments || ':' || ArgumentsValues, p_checksum_type => 'SESSION');

with :

-- for example
Arguments := 'param1,param2'; 
ArgumentsValue := 'value1,value2'; 

该命令工作正常,但 URL 缺少会话。

返回的 URL 是:

https://www.example.com/ords/schema/r/myapp/pagealias?
param1=value1&
param2=value2&
cs=3BSsM-dn0SHfT0DBLYTRIHlSC_71paQVC0VQ_Hfa6YuVc-DzsnTzEs6yH

现在我需要将会话包含在 URL 中。这意味着在 URL 的末尾,我应该

&session=45654654987

尝试手动添加会话,例如:

Output := Output || '&session=' || v('APP_SESSION');

这仅适用于标准页面,不适用于模式页面。因此,对于模态页面,我正在做这样的事情:

-- Output generated from APEX_UTIL.PREPARE_URL :
javascript:apex.navigation.dialog(
        '\u002Fords\u002Fschema\u002Fr\u002Fmyapp\u002pagealias?
        param1=value1\u0026
        param2=value2\u0026
        cs=3_XtJdikM6ypsgs1BPNLnh3dKfHI5-gbFl0YMA78wn032WRoN8Z4PoFDOmQJ9RvaMkW1q-Uk-x9BNEaunXyY_hw\u0026
        dialogCs=fC8UqaERKj1k7OONTBxSKhPe4GeVKJ4Mk0nSTNDMRIR0o5hpagnDAKoNiYHzqcWo5Q6FgikwEvkbfQBdNE7MtQ',
        {title:'Page title',height:'auto',width:'720',maxWidth:'960',modal:true,dialog:null},'t-Dialog-page--standard '+'',apex.jQuery('#regionId'));

修复它的技巧:

Output := replace(Output, ',{title' , '&session=' || v('APP_SESSION') || ',{title');

返回

javascript:apex.navigation.dialog(
        '\u002Fords\u002Fschema\u002Fr\u002Fmyapp\u002pagealias?
        param1=value1\u0026
        param2=value2\u0026
        cs=3_XtJdikM6ypsgs1BPNLnh3dKfHI5-gbFl0YMA78wn032WRoN8Z4PoFDOmQJ9RvaMkW1q-Uk-x9BNEaunXyY_hw\u0026
        dialogCs=fC8UqaERKj1k7OONTBxSKhPe4GeVKJ4Mk0nSTNDMRIR0o5hpagnDAKoNiYHzqcWo5Q6FgikwEvkbfQBdNE7MtQ&
        session=98798798797',
        {title:'Page title',height:'auto',width:'720',maxWidth:'960',modal:true,dialog:null},'t-Dialog-page--standard '+'',apex.jQuery('#regionId'));

有没有更好的方法来做到这一点?

I'm running Apex 20.1 and I need to generate some URLs that includes the checksum and the session (that's mandatory).

I'm doing :

Output := APEX_UTIL.PREPARE_URL(p_url => 'f?p=' || ApplicationAlias || ':' || PageAlias || ':' || SessionId ||'::::' || Arguments || ':' || ArgumentsValues, p_checksum_type => 'SESSION');

with :

-- for example
Arguments := 'param1,param2'; 
ArgumentsValue := 'value1,value2'; 

This command works properly but the URL is missing the session.

The URL Returned is :

https://www.example.com/ords/schema/r/myapp/pagealias?
param1=value1&
param2=value2&
cs=3BSsM-dn0SHfT0DBLYTRIHlSC_71paQVC0VQ_Hfa6YuVc-DzsnTzEs6yH

Now I need to have the session included in the URL. This means at the end of the URL I should have

&session=45654654987

I tried adding the session manually like :

Output := Output || '&session=' || v('APP_SESSION');

This works only for standard pages and not modal pages. So for modal pages I'm doing like :

-- Output generated from APEX_UTIL.PREPARE_URL :
javascript:apex.navigation.dialog(
        '\u002Fords\u002Fschema\u002Fr\u002Fmyapp\u002pagealias?
        param1=value1\u0026
        param2=value2\u0026
        cs=3_XtJdikM6ypsgs1BPNLnh3dKfHI5-gbFl0YMA78wn032WRoN8Z4PoFDOmQJ9RvaMkW1q-Uk-x9BNEaunXyY_hw\u0026
        dialogCs=fC8UqaERKj1k7OONTBxSKhPe4GeVKJ4Mk0nSTNDMRIR0o5hpagnDAKoNiYHzqcWo5Q6FgikwEvkbfQBdNE7MtQ',
        {title:'Page title',height:'auto',width:'720',maxWidth:'960',modal:true,dialog:null},'t-Dialog-page--standard '+'',apex.jQuery('#regionId'));

Trick to fix it :

Output := replace(Output, ',{title' , '&session=' || v('APP_SESSION') || ',{title');

That returns

javascript:apex.navigation.dialog(
        '\u002Fords\u002Fschema\u002Fr\u002Fmyapp\u002pagealias?
        param1=value1\u0026
        param2=value2\u0026
        cs=3_XtJdikM6ypsgs1BPNLnh3dKfHI5-gbFl0YMA78wn032WRoN8Z4PoFDOmQJ9RvaMkW1q-Uk-x9BNEaunXyY_hw\u0026
        dialogCs=fC8UqaERKj1k7OONTBxSKhPe4GeVKJ4Mk0nSTNDMRIR0o5hpagnDAKoNiYHzqcWo5Q6FgikwEvkbfQBdNE7MtQ&
        session=98798798797',
        {title:'Page title',height:'auto',width:'720',maxWidth:'960',modal:true,dialog:null},'t-Dialog-page--standard '+'',apex.jQuery('#regionId'));

Is there any better way to do this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幽梦紫曦~ 2025-01-19 21:18:07

您是否尝试使用 APEX_PAGE.GET_URL?在 APEX 21.2 文档APEX_UTIL.PREPARE_URL,建议使用APEX_PAGE.GET_URL而不是APEX_UTIL.PREPARE_URL

APEX_PAGE.GET_URL 有一个包含 APEX 会话 ID 的参数,因此它应该根据您要导航到的页面类型将会话 ID 正确构建到 URL 中。只要您在与当前会话相同的工作区中导航,校验和也会自动在 URL 中生成。

如果您导航到的页面的应用程序启用了“友好 URL”,APEX_PAGE.GET_URL 还将以“友好”语法返回 URL。

Instead of using APEX_UTL.PREPARE_URL, have you tried using APEX_PAGE.GET_URL? In the APEX 21.2 documentation for APEX_UTIL.PREPARE_URL, it is recommended to use APEX_PAGE.GET_URL instead of APEX_UTIL.PREPARE_URL.

APEX_PAGE.GET_URL has a parameter to include the APEX session id so it should properly build the session id into the URL depending the type of page you are navigating to. The checksum will also automatically be generated in the URL as long as you are navigating within the same workspace as your current session.

APEX_PAGE.GET_URL will also return the URL in "friendly" syntax if "friendly URLs" are enabled for the application of the page you are navigating to.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文