Oracle APEX 5.0: How-to call modal page from dynamic action and capture close event

Today I needed to submit a page saving data and opening a modal page afterwards. For my surprise, APEX 5.0 raises an “400 – Bad request” error when calling a modal page from “Branch” section after processesing (calls apex.navigation.dialog without stating “javascript:” sentence first). It seems to be a Bug of 5.0 version (which hopefuly might be solved at 5.1). Since I had to bypass this error I used the following workaround which provides fully APEX integration.

1. Create one item called PX_URL which will contain APEX modal Page URL to call.

The trick here is to prepare URL passing p_triggering_element parameter. This element identifies jQuery element which opens Modal window so that it can be retrieved properly on close. In my case, modal could be opened from any button so I informed “body” so that any request captures Close Dialog event. Assuming, for instance, modal page is 150:

apex_urlitem_prepare

This dynamic action should be conditional so that it only opens on-demand. In my case I created another item called PX_FLAG_MODAL calls modal window when its set to “Y”. So my first step is setting back PX_FLAG_MODAL back to “N” in order to avoid a modal loop.

2. Create a conditional Dynamic Action  “On Page Load” which executes the following javascript code, which executes PX_URL content and opens modal window:

javascript_eval_url

 

3. If you need to capture On Close dialog event, you have to define a Dynamic Action on “Dialog Closed” which captures jQuery Selector “body” element:

oncloseeventdialog

 

Hope it helps!

 

Tags: ,

One Response to “Oracle APEX 5.0: How-to call modal page from dynamic action and capture close event”

  1. David Kyánek 27/12/2016 at 13:43 #

    Hi,

    I suggest use this:

    apex.navigation.redirect(apex.item(‘PX_URL’).getValue());

    rather than using function eval().

    David

Leave a Reply

Oracle APEX 5.0: How-to call modal page from dynamic action and capture close event

Today I needed to submit a page saving data and opening a modal page afterwards. For my surprise, APEX 5.0 raises an “400 – Bad request” error when calling a modal page from “Branch” section after processesing (calls apex.navigation.dialog without stating “javascript:” sentence first). It seems to be a Bug of 5.0 version (which hopefuly might be solved at 5.1). Since I had to bypass this error I used the following workaround which provides fully APEX integration.

1. Create one item called PX_URL which will contain APEX modal Page URL to call.

The trick here is to prepare URL passing p_triggering_element parameter. This element identifies jQuery element which opens Modal window so that it can be retrieved properly on close. In my case, modal could be opened from any button so I informed “body” so that any request captures Close Dialog event. Assuming, for instance, modal page is 150:

apex_urlitem_prepare

This dynamic action should be conditional so that it only opens on-demand. In my case I created another item called PX_FLAG_MODAL calls modal window when its set to “Y”. So my first step is setting back PX_FLAG_MODAL back to “N” in order to avoid a modal loop.

2. Create a conditional Dynamic Action  “On Page Load” which executes the following javascript code, which executes PX_URL content and opens modal window:

javascript_eval_url

 

3. If you need to capture On Close dialog event, you have to define a Dynamic Action on “Dialog Closed” which captures jQuery Selector “body” element:

oncloseeventdialog

 

Hope it helps!

 

Tags: ,

One Response to “Oracle APEX 5.0: How-to call modal page from dynamic action and capture close event”

  1. David Kyánek 27/12/2016 at 13:43 #

    Hi,

    I suggest use this:

    apex.navigation.redirect(apex.item(‘PX_URL’).getValue());

    rather than using function eval().

    David

Leave a Reply