I just ran into a situation where I needed to pass back a value from a pop-up page to a tabular form item in the calling page. While I've done this in the past ny manually writing all of the JavaScript, I thought that I'd take a look at the new documented APEX JavaScript APIs.
I came across this function in the APEX 3.2 API Reference Guide (Part #E13369-01):
Looks perfect! In addition to passing the value back, it will also close the pop-up page, even though that is not documented.
On the pop-up page, I created a link with an Optional Redirect to URL, and put the following in the link:
P3_NODE is the DOM ID of the tabular form item that I wanted to return the value to. You'll need to make sure that it's formatted properly for this to work. Thus, I am passing in a "1", but returning "f03_0001". A simple computation can do the trick.
Since we're using a built-in tabular form, we need to put the calling JavaScript in the Element Attributes of the item that we want the popup form to set. I used this:
This will pop open a new window, based on page 3 of my application. It will also grab the Application ID and Session ID from the DOM and use those in the link, so that we preserve our session state. Finally, it will pass along the corresponding ROWNUM of the item that we clicked on to the item P3_NODE - where I will make the proper transformation with the computation on Page 3. Lastly, the readonly option prevents users from making direct changes to the item.
Point taken from this - have a look at the APEX API guide before you embark on writing your own code. There are a number of helpful functions there than can save a lot of time and hassle.
I came across this function in the APEX 3.2 API Reference Guide (Part #E13369-01):
$v_PopupReturn(pValue, pThat)
Sets the value of the item in the parent window (pThat), with (pValue) and then
closes the popup window.
Return Value
Not applicable.
Parameters
pValue (string)
pThat (DOM node | string ID)
Looks perfect! In addition to passing the value back, it will also close the pop-up page, even though that is not documented.
On the pop-up page, I created a link with an Optional Redirect to URL, and put the following in the link:
javascript:$v_PopupReturn(#EMPNO#, '&P3_NODE.')
P3_NODE is the DOM ID of the tabular form item that I wanted to return the value to. You'll need to make sure that it's formatted properly for this to work. Thus, I am passing in a "1", but returning "f03_0001". A simple computation can do the trick.
Since we're using a built-in tabular form, we need to put the calling JavaScript in the Element Attributes of the item that we want the popup form to set. I used this:
onclick="popUp2('f?p=' + $v('pFlowId') + ':3:'
+ $v('pInstance') + '::::P3_NODE:#ROWNUM#',250,600);" readonly
This will pop open a new window, based on page 3 of my application. It will also grab the Application ID and Session ID from the DOM and use those in the link, so that we preserve our session state. Finally, it will pass along the corresponding ROWNUM of the item that we clicked on to the item P3_NODE - where I will make the proper transformation with the computation on Page 3. Lastly, the readonly option prevents users from making direct changes to the item.
Point taken from this - have a look at the APEX API guide before you embark on writing your own code. There are a number of helpful functions there than can save a lot of time and hassle.
Comments
Guess, one more reason to update to the newest version.
Thanks -Scott- for sharing.
-Taj
"$v_PopupReturn(pValue, pThat)
Sets the value of the item in the parent window (pThat), with (pValue) and then
closes the popup window."
You wrote:
"it will also close the pop-up page, even though that is not documented."
Assuming the first is a copy-paste from the documentation, I think your statement needs revision :-)
Thanks for the correction.
- Scott -
http://jqueryui.com/demos/dialog/
Sujay
Thanks,
- Scott -
Do you have any applications where I can see how this has been implemented?
I am using APEX 4.0.Can we use the same in 4.0 too?
- Scott -
In my case its just blank. The page closes so I know it works.
Chhers.