8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux
APEX Tips : Return a Value From a Modal Dialog
Related articles.
Requirement
We have two pages.
- Source Page : A normal page with a Text Field called
P2_SOURCE_VALUE
and a button calledOPEN_MODAL
. - Modal Dialog : A modal dialog with a Text Field called
P3_MODAL_VALUE
and a button calledCLOSE_MODAL
.
We need the following behaviour.
- On the Source Page, when we click the
OPEN_MODAL
button we want to open the Modal Dialog. - On the Modal Dialog, when we click the
CLOSE_MODAL
button we want to pass the value of theP3_MODAL_VALUE
item back to theP2_SOURCE_VALUE
item.
Modal Dialog Setup
- Create a Dynamic Action on the
CLOSE_MODAL
button with the following settings.
- Name: onClick CloseDialog (amend as required)
- Event: Click
- Selection Type: Button
- Button:
CLOSE_MODAL
- The "Behaviour" setting of the
CLOSE_MODAL
button should now default to "Defined by Dynamic Action". - Edit the default True action as follows.
- Action: CloseDialog
- Items to Return:
P3_MODAL_VALUE
Source Page Setup
- The
OPEN_MODAL
button should have the following "Behaviour" settings.
- Action: Redirect to Page in this Application.
- Target: Page 3. In this example we aren't passing any values, but we will set the "Clear Cache" attribute to page "3" in the "Link Builder - Target" popup.
- Create a Dynamic Action on the
OPEN_MODAL
button with the following settings.
- Name: DialogClosed (amend as required)
- Event: Dialog Closed
- Selection Type: Button
- Button:
OPEN_MODAL
- Edit the default True action as follows.
- Action: SetValue
- Set Type: Dialog Return Item
- Return Item:
P3_MODAL_VALUE
- Selection Type: Item(s)
- Item(s):
P2_SOURCE_VALUE
Test It
It should now work as required.
For more information see:
Hope this helps. Regards Tim...