【问题标题】:APEX set item value & session state with javascriptAPEX 使用 javascript 设置项目值和会话状态
【发布时间】:2018-11-03 09:26:40
【问题描述】:

我正在尝试在 oracle apex 中使用 Javascript 设置值和会话状态。这是我调用的函数:

function setItemValue(node) {
    $s('P2020_SELECTED', node);

    apex.server.process ('MY_PROCESS', {
         p_arg_name: 'P2020_SELECTED',
         p_arg_value: node
      });
    } 

将设置显示值(第 2 行),但不会设置会话状态。我在 apex 页面加载时收到此错误。

Error: SyntaxError: Unexpected token P in JSON at position 0

【问题讨论】:

    标签: javascript oracle oracle-apex


    【解决方案1】:

    试试这个:

    function setItemValue(node) {
      $s('P2020_SELECTED', node);              
      apex.server.process('MY_PROCESS',{
        pageItems: '#P2020_SELECTED'
      },{dataType: "text"});
    } 
    

    【讨论】:

    • 特别是如果他们在 PL/SQL 过程中的某处使用 htp.p,并且它不会形成有效的 JSON 字符串。
    【解决方案2】:

    这里有另一种解决方案

    function setSessionState(pItemName){
        apex.server.process(
            "Dummy Process to Set Session State",
            {  
                pageItems: "#" + pItemName
            },
            {
                async: true, --> change here if you need sync/async
                "dataType": "text",
                "success": function(data){
                    void(0);
                }
            }
        );
    }
    

    【讨论】:

    【解决方案3】:

    为了进一步改进上面的答案,这是我的工作示例(当前为 APEX 19.2)

    apex.server.process(
    /* I would suggest creating an Application Process named DUMMY as Ajax Callback with a NULL; content */
    "DUMMY",
    {pageItems: "#P4_GROUP_ID"}, /* Add comma delimited items eg. #P1,#P2,#P3 */
    {
        dataType: "text",
        async: true, /* Async should be true in order to be Asynchronous and then execute your code on success */
        success: function(data) {
            console.log("completed");
            console.log(data);
            apex.region('group-positions').refresh();
            apex.region('group-departments').refresh();
            apex.region('group-instructors').refresh();
            apex.region('group-attends').refresh();
        }
    }
    

    );

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多