• Calling 2 xe:dialogs one after another on the same XPage not working

    By Ionut Ichim 1 decade ago

    On the same XPage I have 2 xe:dialog controls pre-implemented as custom controls, and added then to this page. Both dialogs need to be shown during some actions, but the second needs to be shown after some calculations of the first. I implemented this as follows:

    First dialog is for showing a comment box for the user to enter something:

    The first dialog opens normally with
    dlg1 = getComponent("

    ");
    dlg1.show();


    in the OK button of it the dialog 1 is a SSJS which writes its changes to viewScope variables, tells itself to hide with

    dlg1 = getComponent("");
    dlg1.hide("");
      -this panel contains the other dialog 2

    and after writing something to viewScope variables checking if the document has a specific flag set (like the document is of a specific type X) it tries to open the second dialog:

    dlg2 = getComponent("");
    dlg2.show();  -> during this instruction I get a runtime error with the reason that the dlg object is null !!  as it would be neither renderred nor available !

    I'm using the Xpage Extension library downloaded from this link and I installed the library on both server and client 8.5.2FP3:

    Aug 29, 2011 Philippe Riand 8.5.2.201108271850NTF 353

    Any idea what to do in this case ?  I won't like to put the content of the first and the second dialog together in a third dialog to be called only if the condition for the second dialog is fulfilled.

     

    Thank you in advance,

    Ionut Ichim

    • it might be an issue with the context

      By Philippe Riand 1 decade ago

      Can you please isolate the issue is a piece of code and attach it to this thread?

      • Problem isolated in a zipped database but with change side effects

        By Ionut Ichim 1 decade ago

        Hello, Phillipe

        Thank you for looking into this.

        I isolated the problematic functionality as good as I could in this attached zipped db.

        The error as reported in my initial posting is in this form not reproducible. All I can say now is that it would happen in the function closeDialog1AndShowDialog2() when attempting to access the dialog2 as component and to show it.

        Now there is still a different error coming as server-side confirmation box:

        Problem submitting an area of the page.
           Unable to load http://darkstar.dino/asap/Ionut/test2xedialogs.nsf/test2xe_dialogs.xsp?$$ajaxmode=full&$$ajaxid=view%3A_id1%3A_id2%3A_id21%3Adialog1%3A_content status:500
        Submit the entire page?

        OK Cancel -buttons

        Maybe the changed behaviour depends on the October Version of the Ext Lib I installed in the mean time.

        In any case it would be great I there would be a possibility in the OK button of  dialog1 to tell to this dialog to hide and dialog2 to show.

        Best regards,

        Ionut Ichim

        • Database is encrypted

          By Philippe Riand 1 decade ago

          So I can't access it. Please attach an non encrypted version, withe a cleared ACL.

          • Unecrypted database

            By Ionut Ichim 1 decade ago

            Sorry, attached below is the unencrypted database.

    • There are 2 issues with this code

      By Philippe Riand 1 decade ago

      1- getComponent('dialog2') is returning null because dialog2 is not a component inside dialog1. And this is not handled by the getComponent() method. The workaround is to use a Java method from FacesUtil instead

      2- There is a race condition between the close dialog request and the open dialog2 one. I don't understand all the details, but when you open the dialog2 later then it works. The workaround is, for example, to do it after 500ms.

      Bellow is a modified function that makes it works. Note that it requires 853 as the postScript method ia a new addition to this release.

      That said, chaining the dialogs like this is generally considered as a bad user experience.

      function closeDialog1AndShowDialog2() {
       
      var dialog1 = getComponent("dialog1");
        dialog1.hide("dialogPanel");
        var dialog2 = com.ibm.xsp.util.FacesUtil.getComponentFor(view, "dialog2")
        view.postScript("setTimeout(function() {XSP.openDialog('"+dialog2.getClientId(facesContext)+"')},500);");
        dialog2.show();
      }

       

      • Re: workaround

        By Ionut Ichim 1 decade ago

        Hi, Philippe,

        thank you very much for the work-around as well as for the hint with the bad user experience. I agree with you on that.

        I'll test it as soon I have 853 Client and server (using now 852).

        Best regards,

        Ionut