Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Plugins, how to pass values from javascript to the plugin backend pl/sql code?

BotzyMay 25 2023 — edited May 25 2023

I hope I can master to explain my issue well enough. I have made a plugin that is a region that pops up as a modal dialog, for users to enter details into.

The page will hold this region plugin inside an inline dialog region, in the "Dialogs, Drawers and Popups" section of the page. The user experience is like this:

  • User selects a row in a grid, and that sets an ITEM_ID value on the page, corresponding to the line that the user selected
  • The plugin needs to know about this ITEM_ID, before it pops up as a modal dialog, because it needs to set some defaults and then to render the plugin with that ITEM_ID in mind

My problem is that as an inline dialog popup, the plugin is being rendered before the user has selected any row in the grid, hence doesn't know about the ITEM_ID when it is being rendered.

I have tried various things to make the popup refresh first, and then display the plugin rendered based on the ITEM_ID of the page that invoked it, but the ITEM_ID isn't registered. I do get it correct if I first press F5 to refresh the entire page, and then make the modal popup, but the ITEM_ID is being delayed, example:

  • User loads the page, and selects ITEM_ID: 3 - then the plugin shows nothing
  • User then presses F5 to reload, and now selects ITEM_ID: 7 - then the plugin shows ITEM_ID: 3

Here's how I try to setting the ITEM_ID to the serverside, so that the plugin can see the value:

function showAcctPopup(ITEM_ID) {
   $s('P20_ITEM_ID', ITEM_ID);
   apex.region("REGION_CONTAINING_PLUGIN").refresh();
   openModal('REGION_CONTAINING_PLUGIN');  
}

I also made a dynamic action on the P20_ITEM_ID to react when that value changes, and there I execute server-side pl/sql code, to make sure that the user-selected-value reaches the server/backend:

I even notice the value being sent to the serverside, by inspecting the browser's network console. Still the plugin doesn't see any other value, than the value that was present when the page was initially loaded (by using F5/refresh).

Is my approach wrong, or how would you suggest to do this in a plugin, to send a value to the plugin's render-code, from a page using javascript? Are there better ways to make this work?

This post has been answered by Toufiq-Oracle APEX PM-Oracle on May 25 2023
Jump to Answer
Comments
Post Details
Added on May 25 2023
7 comments
402 views