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.

Refresh of application after modal dialog close clicked from a Navigation menu

Arijit KanrarDec 31 2019 — edited Jan 2 2020

Hello gurus,

Requesting help on the way to proceed with this issue I'm facing.

I'm running Apex 5.1.3.00.05 on a Oracle 11g server.

I have a modal dialog page (lets call it the Set Status page) which sets the status of an operation. This page is launched from the Nav menu.

The page has a select list to set the current status and a button which fires a DA to set the value in the session into a page level item and close the modal dialog.

I use this page level item as a substitution variable for some of the items on the Nav menu so the menu indicates the current status.

So when the user changes the current status and clicks on the Apply button, the application should close the modal dialog and refresh the page so that the new status is reflected on the nav menus.

No refreshing the parent page on close of a modal dialog is easy if the element that launches the dialog is on the page. But in this case the dialog is in the nav menu and hence not on a particular page.

Here is a similar app I created on apex.oracle.com. https://apex.oracle.com/pls/apex/wwv_flow_custom_auth_std.login_page?p_flow_page=102752:1:716999324723112

Please login with any username.

The dialog page opens using the Set Status Value Here link on the nav menu and the value that is set reflects in the other two nav menus.

apex_modal_dialog.PNG

To do this I thought of having a dynamic action on the global page which would respond to a dialog closed event and refresh the page.

But I am not sure what should the 'Selection Type' field be set to. On reading a few threads here on OTN, I set it to Javascript Expression and set the expression to window.

But that didnt work.

I also tried to write custom javascript and use apex JS API and wait for the apexafterclosedialog event to perform the refresh.

As per the documentation here at https://docs.oracle.com/en/database/oracle/application-express/19.2/aexjs/apex.html

it says

This event is triggered on the element that opened the dialog.

For buttons it is the button element. For links to dialog pages in lists it is the list region element. For lists used in global top or side navigation or in any other case where the triggering element cannot be determined the event is triggered on the document apex.gPageContext$.

So I tried to attach an event handler on the apex.gPageContext$ object but that also does not seem to work.

Finally I got it to work by listening for the jQuery dialogclose event and I wrote a handler like this (this runs on initialization on the global page).

function addDialogCloseHandler() {

apex.gPageContext$.on('dialogclose', function (event, data) {

    apex.navigation.redirect('f?p=&APP\_ID.:&APP\_PAGE\_ID.:&APP\_SESSION.::::');

});

}

addDialogCloseHandler();

Although not very elegant, it works to an extent.

However, there are problems with this approach.

It is not specific which means it will fire on close of any dialog. It seems to be very hard to make it fire for a specific modal dialog only).

I was wondering if there is a more "Apex" way of doing this? Am I missing somethings from the doc?

Thanks.

Arijit

Message was edited by: Arijit Kanrar Added more details.

This post has been answered by Franck N on Dec 31 2019
Jump to Answer
Comments
Post Details
Added on Dec 31 2019
4 comments
3,515 views