20231007 - Generate APEX URL in JavaScript



var vItemValue = 'New Item Value';

// Example 1 - get URL to set item value on page 1 with value from variable vItemValue
var vUrl = "f?p=" + $v( "pFlowId" ) + ":1:" + $v( "pInstance" ) + "::" + $v( "pdebug" ) + "::P1_ITEM:"+vItemValue;

// Example 2 - get URL to set item value on current page with value from variable vItemValue
var vUrl = "f?p=" + $v( "pFlowId" ) + ":" + $v( "pFlowStepId" ) + ":" + $v( "pInstance" ) + "::" + $v( "pdebug" ) + "::P1_ITEM:"+vItemValue;

// redirect to generated URL
apex.navigation.redirect(vUrl);

 


var vItemValue = 'New Item Value';

// Example 1 - just get URL to go to the page 1
vUrl = apex.util.makeApplicationUrl({pageId:1);

// Example 2 - go to page 1 and set value of item P1_ITEM
vUrl = apex.util.makeApplicationUrl({
  pageId:1,
  itemNames:['P1_ITEM'],
  itemValues:[vItemValue]
});

// Example 3 - you can also set multiple items
var vItem2Value = 'New Item 2 Value';
vUrl = apex.util.makeApplicationUrl({
  pageId:1,
  itemNames:['P1_ITEM', 'P1_ITEM_2'],
  itemValues:[vItemValue, vItem2Value]
});

// Example 4 - all options
vUrl = apex.util.makeApplicationUrl({
  appId: 100,                   // default is $v("pFlowId") - current app
  pageId:1,                     // default is $v("pFlowStepId") - current page
  session: $v( "pInstance" ),   // default is $v("pInstance") - current session
  request: 'TEST_REQUEST',      // default is $v("pRequest") - current request
  debug: 'YES',                 // default is $v("pdebug") - debug YES/NO
  itemNames:['P1_ITEM'],        // item names array (no value by default)
  itemValues:[vItemValue],      // item values array (no value by default)
  printerFriendly: 'YES'        // no value by default
});


--------------------- 다른 방법 : 서버스크립트 + 자바스크립트

서버스크립트


begin
  if :P15_SID is not null then
    :P15_REDIRECT_URL := apex_util.prepare_url('f?p=&APP_ID.:Store:&APP_SESSION.::NO:RP,7:P7_SID:'||:P15_SID);
  else
    :P15_REDIRECT_URL := apex_util.prepare_url('f?p=&APP_ID.:Home:&APP_SESSION.::NO:RP::');
  end if;
end;

자바스크립트


apex.navigation.redirect (apex.item("P15_REDIRECT_URL").getValue());


참고

http://apexbyg.blogspot.com/2019/05/generate-apex-url-in-javascript.html


20231006 - AJAX 에러 핸들링 with PL/SQL JSON 결과 리턴

PL/SQL :


  if l_sid_om != l_sid_m then
    apex_json.open_object;
    apex_json.write('error', true);
    apex_json.write('code', 'ECD-1');
    apex_json.close_object;
    return;
  end if;

  apex_json.open_object;
  apex_json.write('success', true);
  apex_json.write('message', '담기 성공!');
  apex_json.close_object;



Javascript :


apex.server.process('AJAX-ADDtoCART2', {
  x01: selectedMODIDs,
  x02: buttonQty,
  x03: initialPrice,
  pageItems: "#P13_SID,#P13_MID,#P13_MNM,#P13_UMID"
}, {
  success: function(data) {
    apex.message.showPageSuccess(data.message);
    setTimeout(function() {
      OnClickBack();
    }, 1000);
  },
  error: function(xhr, status, error) {
    var JSONCD = xhr.responseJSON.code;
    var vTitle, vText;
    if (JSONCD == "ECD-1") {
        vTitle = "매장확인필요";
        vText  = "장바구니에 저장된 메뉴의 매장과 추가로 담으려는 매장이 다릅니다. 다른 매장의 메뉴와 같이 주문할 수 없습니다.";
    }

    apex.message.alert(vText, function(){
    }, {
        title: vTitle,
        style: "warning"
    } );
  }  
});






참고
https://docs.oracle.com/en/database/oracle/apex/23.1/aexjs/apex.server.html#.process
https://docs.oracle.com/en/database/oracle/apex/23.1/aexjs/apex.message.html#.showErrors

20250202 - IG 다운로드 버튼 바로 보이기

JS initialization Code : function (config) {     var $ = apex.jQuery,         toolbarData = $.apex.interactiveGrid.copyDefaultToolbar(),  ...