12 Replies Latest reply on Mar 21, 2019 12:05 PM by fac586

    Returning and displaying a value to the calling page from a modal pop-up

    Laury

      Hi,

       

      I am working with APEX 5.x.

       

      I have on Page=42, item P42_EXISTING_CUSTOMER.

      This item is populated from a Select-list and can be displayed with a process in Page Processing, when I press the button CONFIRM.

      On this page, I also have item P42_CUSTOMER_ID.

       

      I have on Page=42, the button SHOW that, when pressed open a modal pop-page through an after processing branch in Page Branches.

      The modal pop-up page is page=204. Item P204_CUSTOMER_ID gets the value of P42_EXISTING_CUSTOMER through the branching process.

       

      How can I combine both processes to have the modal page open when I click on SHOW, and when I close that page, return to page=42, having P42_CUSTOMER_ID getting the value of P42_EXISTING_CUSTOMER or P204_CUSTOMER_ID and being displayed on page=42?

      I am thinking about a kind of "automatic" refresh when I close the modal pop-up page, but how to implement it?

       

      Thanks by advance for any tip.

       

      Kind Regards.

        • 1. Re: Returning and displaying a value to the calling page from a modal pop-up
          fac586

          Laury wrote:

           

          I am working with APEX 5.x.

           

          I have on Page=42, item P42_EXISTING_CUSTOMER.

          This item is populated from a Select-list and can be displayed with a process in Page Processing, when I press the button CONFIRM.

          On this page, I also have item P42_CUSTOMER_ID.

           

          I have on Page=42, the button SHOW that, when pressed open a modal pop-page through an after processing branch in Page Branches.

          The modal pop-up page is page=204. Item P204_CUSTOMER_ID gets the value of P42_EXISTING_CUSTOMER through the branching process.

           

          How can I combine both processes to have the modal page open when I click on SHOW, and when I close that page, return to page=42, having P42_CUSTOMER_ID getting the value of P42_EXISTING_CUSTOMER or P204_CUSTOMER_ID and being displayed on page=42?

          What is the purpose of the dialog page? Does it change the value of P204_CUSTOMER_ID? Otherwise from the description above all that happens is that P42_EXISTING_CUSTOMER is copied to P42_CUSTOMER_ID via a roundabout route.

          • 2. Re: Returning and displaying a value to the calling page from a modal pop-up
            Laury

            Page=42 displays some generic information.

            Page=204 displays details information from page=42 (as pop-up modal page).

            No, the modal page does not change any value, It just displays some more details.

            P42_EXISTING_CUSTOMER is copied to P204_CUSTOMER_ID, hence the pop-up page.

            But I cannot get P42_EXISTING_CUSTOMER assigned to P42_CUSTOMER_ID when I close the modal page.

            • 3. Re: Returning and displaying a value to the calling page from a modal pop-up
              fac586

              Laury wrote:

               

              Page=42 displays some generic information.

              Page=204 displays details information from page=42 (as pop-up modal page).

              No, the modal page does not change any value, It just displays some more details.

              P42_EXISTING_CUSTOMER is copied to P204_CUSTOMER_ID, hence the pop-up page.

              But I cannot get P42_EXISTING_CUSTOMER assigned to P42_CUSTOMER_ID when I close the modal page.

              Doesn't sound like anything more complicated than a Dialog Closed dynamic action with a Set Value step is required.

              • 4. Re: Returning and displaying a value to the calling page from a modal pop-up
                Laury

                What to chose then for "Selection" Type?

                What "Set Type"?

                 

                Modal page = 204

                 

                If I have a dynamic action on Page Rendering:

                 

                Identification:

                    Action: Set Value

                Execution Options:

                     Fire When Event Result Is: true

                     Fire On Page Load: selected

                     Stop Execution On Error: selected

                     Wait For Result: selected

                Settings:

                    Set Type: JavaScript Expression

                    JavaScript Expression: $v('P42_CUSTOMER_ID') = $v('P204_CUSTOMER_ID');

                Affected Elements:

                    Selection Type: Item(s)

                    Items=(s):P204_CUSTOMER_ID

                 

                It stil does not work when I close the modap page.

                The value of P204_CUSTOMER_ID is not propagated back to P42_CUSTOMER_ID, on the calling page.

                • 5. Re: Returning and displaying a value to the calling page from a modal pop-up
                  fac586

                  Laury wrote:

                   

                  What to chose then for "Selection" Type?

                  The element used to open the dialog page, i.e. the CONFIRM button.

                  What "Set Type"?

                  JavaScript Expression: $v("P42_EXISTING_CUSTOMER")

                  Fire On Page Load: selected

                  This should be set to No.

                  Affected Elements:

                  Selection Type: Item(s)

                  Items=(s):P204_CUSTOMER_ID

                  This should be Item(s) and P42_CUSTOMER_ID.

                  • 6. Re: Returning and displaying a value to the calling page from a modal pop-up
                    Laury

                    I understood that the dynamic action should be created on the modal page.

                    But on the modal page, I have no buton only the X button on the top-right corner.

                     

                    Why the CONFIRM button?

                    This is a button on the calling page.

                    This button passes only the value P42_EXISTING_CUSTOMER or P204_CUSTOMER_ID .

                     

                    The SHOW button on the calling page is intended to open the modal page (pop-up) and when closing it, should assign P204_CUSTOMER_ID to P42_CUSTOMER_ID,

                    back on the calliing page, and showing this value when the modal page is closed with the X button on the top-right corner.

                     

                    Should this dynamic action be created on the calling page instead?

                     

                    If I have this dynamic view on the calliong page:

                     

                    Name: XX

                    Event: Dialog Closed

                    Selection Type: Button

                    Button: SHOW

                    Acion: Execute JavaScript Code

                    Code: $v("P42_EXISTING_CUSTOMER")

                    Selection Type: Item(s)

                    Item(s): P42_CUSTOMER_ID

                     

                    Fire When Event Result Is: true

                    Fire On Page Load: checked

                     

                    It still doesn not work.

                    • 7. Re: Returning and displaying a value to the calling page from a modal pop-up
                      fac586

                      Laury wrote:

                       

                      I understood that the dynamic action should be created on the modal page.

                      No, the Dialog Closed DA must be on the calling page.

                       

                      Do not confuse the Dialog Closed event (which is triggered on the calling page) with the Close/Cancel Dialog actions and Close Dialog process type which exist on the dialog page.

                      But on the modal page, I have no buton only the X button on the top-right corner.

                      In which case the Dialog Closed DA will not execute: how to trigger DA when user clicks a standard close window button

                      Why the CONFIRM button?

                      This is a button on the calling page.

                      Because the Dialog Closed event occurs on the calling page.

                      This button passes only the value P42_EXISTING_CUSTOMER or P204_CUSTOMER_ID .

                       

                      The SHOW button on the calling page is intended to open the modal page (pop-up) and when closing it, should assign P204_CUSTOMER_ID to P42_CUSTOMER_ID,

                      back on the calliing page, and showing this value when the modal page is closed with the X button on the top-right corner.

                       

                      Should this dynamic action be created on the calling page instead?

                      Yes, but under normal circumstances it isn't going to execute when the dialog is cancelled by clicking the UI close button or pressing the Escape key.

                       

                      What is the purpose of all this?

                       

                      From the information provided so far, the values of P42_EXISTING _CUSTOMER and P204_CUSTOMER_ID are identical. Page 204 does not modify P204_CUSTOMER_ID. There is therefore no need to pass P204_CUSTOMER_ID back to page 42 as it is already available there as P42_EXISTING_CUSTOMER. If the user can take no material action on page 204 other than closing the dialog (as appears to be indicated by the dialog containing no buttons), there is no obvious need to respond to closing the dialog. Adding a Set Value action to copy P42_EXISTING_CUSTOMER to P42_CUSTOMER_ID on the CONFIRM button Click DA would have exactly the same effect as the proposed Dialog Closed processing, without having to create custom event handlers based on undocumented APIs.

                      • 8. Re: Returning and displaying a value to the calling page from a modal pop-up
                        Laury

                        Yes, P42_EXISTING_CUSTOMER and P204_CUSTOMER_ID are identical.

                        The value of P42_EXISTING_CUSTOMER is passed to P204_CUSTOMER_ID when the modal page is called.

                        Yes, page 204 does not indeed modify P204_CUSTOMER_ID, there is indeed no need to pass P204_CUSTOMER_ID back to page 42 as it is already available there as P42_EXISTING_CUSTOMER.

                        This is the reason why I wrote: having P42_CUSTOMER_ID getting the value of P42_EXISTING_CUSTOMER or P204_CUSTOMER_ID and being displayed on page=42.

                         

                        The two actions that I want to combine are:

                         

                            1) The one done by pressing the SHOW button:

                            This is a button with action When Button Clicked -> Action: Submit Page.

                            I have a branching process when pressing the CONFIRM button that opens the modal page, page=204.

                           

                            2) The one done by pressing the CONFIRM button:

                            This is a button with action When Button Clicked -> Action: Defined by Dynamic Action:

                            Event: Click

                            Selection Type: Button

                            Button: CONFIRM

                            Identification -> Action: Set Value

                            Execution Options -> Fire When Event Result Is: True

                            Execution Options -> Fire On Page Load: checked

                            Settings -> Set Type: JavaScript Expression

                            Settings -> JavaScript Expression: $v("P42_EXISTING_CUSTOMER")

                            Affected Elements -> Selection Type: Item(s)

                            Affected Elements -> Item(s): P42_CUSTOMER_ID

                           

                           

                        Like this, it works. But I would like to have both actions combined by just pressing the CONFIRM button.

                         

                         

                        Why if the user can take no material action on page 204 other than closing the dialog (as appears to be indicated by the dialog containing no buttons) there is no obvious need to respond to closing the dialog?

                        What if the use open then modal page as a kind of confirmation he/she sees is correct and what to proceed further?

                        In this case, he/she just closes the modal page, be back to the calling page, and that the same me go further with the process, that is in this situation P42_CUSTOMER_ID getting the value of P42_EXISTING_CUSTOMER.

                         

                        You said that adding a Set Value action to copy P42_EXISTING_CUSTOMER to P42_CUSTOMER_ID on the CONFIRM button Click DA would have exactly the same effect as the proposed Dialog Closed processing, but I didn't succeed to build it up.

                         

                        I still do not understand how to achieve it.

                        • 9. Re: Returning and displaying a value to the calling page from a modal pop-up
                          Laury

                          From the above link:

                          Re: Returning Item values from - Form Page (Modal Dialog) - Universal Theme

                          I really don't understand how the result is achieved. On the modal page if I try to creatd a DA, I need to fill up Selection Type.

                          If item=button, I have no button. Except for the standard X buttion (top-right) that does not appear on the list.

                          Any other idea?

                          • 10. Re: Returning and displaying a value to the calling page from a modal pop-up
                            fac586

                            Laury wrote:

                             

                            Yes, P42_EXISTING_CUSTOMER and P204_CUSTOMER_ID are identical.

                            The value of P42_EXISTING_CUSTOMER is passed to P204_CUSTOMER_ID when the modal page is called.

                            Yes, page 204 does not indeed modify P204_CUSTOMER_ID, there is indeed no need to pass P204_CUSTOMER_ID back to page 42 as it is already available there as P42_EXISTING_CUSTOMER.

                            This is the reason why I wrote: having P42_CUSTOMER_ID getting the value of P42_EXISTING_CUSTOMER or P204_CUSTOMER_ID and being displayed on page=42.

                             

                            The two actions that I want to combine are:

                             

                            1) The one done by pressing the SHOW button:

                            This is a button with action When Button Clicked -> Action: Submit Page.

                            I have a branching process when pressing the CONFIRM button that opens the modal page, page=204.

                             

                            2) The one done by pressing the CONFIRM button:

                            This is a button with action When Button Clicked -> Action: Defined by Dynamic Action:

                            Event: Click

                            Selection Type: Button

                            Button: CONFIRM

                            Identification -> Action: Set Value

                            Execution Options -> Fire When Event Result Is: True

                            Execution Options -> Fire On Page Load: checked

                            Settings -> Set Type: JavaScript Expression

                            Settings -> JavaScript Expression: $v("P42_EXISTING_CUSTOMER")

                            Affected Elements -> Selection Type: Item(s)

                            Affected Elements -> Item(s): P42_CUSTOMER_ID

                             

                             

                            Like this, it works. But I would like to have both actions combined by just pressing the CONFIRM button.

                             

                             

                            Why if the user can take no material action on page 204 other than closing the dialog (as appears to be indicated by the dialog containing no buttons) there is no obvious need to respond to closing the dialog?

                            What if the use open then modal page as a kind of confirmation he/she sees is correct and what to proceed further?

                            In this case, he/she just closes the modal page, be back to the calling page, and that the same me go further with the process, that is in this situation P42_CUSTOMER_ID getting the value of P42_EXISTING_CUSTOMER.

                             

                            You said that adding a Set Value action to copy P42_EXISTING_CUSTOMER to P42_CUSTOMER_ID on the CONFIRM button Click DA would have exactly the same effect as the proposed Dialog Closed processing, but I didn't succeed to build it up.

                             

                            I still do not understand how to achieve it.

                            Please use the standard forum quoting mechanism to include content from previous posts. I am finding it increasingly difficult to follow these discussions.

                             

                             

                            It is very simple to do this:

                             

                            1. Click the Reply button on the post you want to respond to.
                            2. In the editor window, click the Quote button in the toolbar.
                            3. Click on the grey background of the quoted text, then the text icon on the pop-up that appears.
                            4. Click on the red "x" button on the pop-up Quote toolbar to unquote the text.
                            5. Select the text you want to respond to and click the Quote button in the toolbar.
                            6. Enter your response below.
                            • 11. Re: Returning and displaying a value to the calling page from a modal pop-up
                              fac586

                              Laury wrote:

                               

                              From the above link:

                              Re: Returning Item values from - Form Page (Modal Dialog) - Universal Theme

                              I really don't understand how the result is achieved. On the modal page if I try to creatd a DA, I need to fill up Selection Type.

                              If item=button, I have no button. Except for the standard X buttion (top-right) that does not appear on the list.

                              Following standard UX practice that button is intended to function as a Cancel button that closes the dialog without having any effect.

                              What if the use open then modal page as a kind of confirmation he/she sees is correct and what to proceed further?

                              Then provide explicit OK and Cancel (or equivalent) buttons on the dialog that enable the user to clearly indicate an affirmative or negative response.

                              • 12. Re: Returning and displaying a value to the calling page from a modal pop-up
                                fac586

                                I have created a demo with examples of all 3 of the approaches discussed above:

                                 

                                1. A "passive" dialog as described in the OP where the user can take no action in the dialog other than closing it using the default close button or escape key, so triggering an action on the Click event that displayed the dialog is equivalent to responding to the close dialog event. This all occurs on the base page.
                                2. An "active" dialog where the user can choose between more than one action: confirming the customer is correct by clicking the "OK" button; or dismissing the dialog by clicking "Cancel", the default close button, or pressing the escape key. In this case we use standard APEX functionality:
                                  1. On the dialog page
                                    1. A Cancel Dialog DA on the "Cancel" button.
                                    2. A Close Dialog process invoked by submitting the page using the "OK" button.
                                  2. On the base page
                                    1. A Dialog Closed DA on the button that opened the dialog.
                                3. A "passive" dialog as in option 1, but with the undocumented hack that causes the default close button to trigger the Dialog Closed DA applied to the invoking button. Again this is implemented completely on the base page.

                                 

                                In my opinion option 2 is easily the best solution. In UX terms it enables the user to explicitly confirm that the selected customer is correct, and is entirely implemented using standard, declarative components.