How is a dojo dialog supposed to work?

  • I’m trying to pop a dialog on a link decorated to look like a button. This dialog is so the user may enter some text, which is put in a field on the “underlying” document. Then it should save that document, triggering the normal qSD/pSD sequence with the updated text. If the user clicks Cancel on the dialog it should dump out without doing anything.

  • The old way was to load a form in a pop-up window. JS on the form would read and write data to the appropriate fields and touch off document.submit() if necessary.

  • I’ve poked around here on the Forum and found a handful of posts about dialog boxes on XPages. One led to Mark’s excellent blog on the subject, which appears to be based on Luc’s posts here, given that Mark says he got some of his code “from the forum” and it’s essentially identical to Luc’s. (grin)

  • Based on this research I have a dialog that does “load” using the code below, showing no JS errors in Firebug, but there are a number of curious behaviours:

  1. The dialog isn’t modal. When I click the link ‘button’ the dialog appears with the alert text on top of it.

  2. When I click Ok on the alert, it dismisses both the alert and the dialog.

  3. The page reloads and I get a Notes Object has been recycled error in one of the other custom controls. I see this when a page is refreshed incorrectly on a save.

  4. Even if the <xp:saveDocument /> runs independently, I see no indication that qSD or pSD run. Each and every data source event has a “print” to the console so I can see when they fire, and no such firing occurs.

  5. If the Cancel button eventHandler is uncommented, it triggers that alert dialog on page unload, not on button click. This also prevents navigation away from that page, so if I attempt to load a bookmark, I see “Cancel” in a box, and if I click “Ok”, it remains on that same page, not loading the bookmark. The only way to get off that page is to close down the browser. After “Ok” at the “Cancel” dialog it does at least shut down.

Any clues as to what’s happening here? Thanks for your time…

-------------------------- Link “button” ------------------------------

<xp:panel styleClass=“lotusBtnContainer” style=“margin:2px 10px”>

<xp:link escape=“true” text=“Edocs Comment” id=“Comment” title=“Upload Comment”

rendered=“#{javascript:hasRole(‘[Releaser]’)}” outerStyleClass=“lotusBtn lotusBtnAction”>

<xp:eventHandler event="onclick" submit="true" refreshMode="complete">

  <xp:this.action><xp:saveDocument /></xp:this.action>

  <xp:this.script>

    <xp:executeClientScript><![CDATA[

dijit.byId(“dlgWFNote”).show();

dojo.style(dijit.byId(“dlgWFNote”).domNode, “opacity”, 1);

alert(“Post-dlgWFNote”);

var it=document.getElementById(‘#{id:xpAction}’);

if(it) it.value=“AWN:”+document.getElementById(‘#{id:Comment}’);

    ]]></xp:executeClientScript>

  </xp:this.script>

</xp:eventHandler>

</xp:link>

</xp:panel>

---------------------------- Dialog custom control -------------------------

<?xml version="1.0" encoding="UTF-8"?>

<xp:view xmlns:xp=“http://www.ibm.com/xsp/core”>

xp:this.resources

<xp:styleSheet href="/OneUIDummy.css"></xp:styleSheet>

</xp:this.resources>

<xp:table styleClass=“lotusInfoTable”>

<xp:tr><xp:td>

  <xp:label value="  Enter comment to be uploaded to eDocs:" id="ulLabel" />

</xp:td></xp:tr>

<xp:tr><xp:td style="text-align:center">

  <xp:inputTextarea id="Comments" style="width:95.0%;text-align:left;height:10em" />

</xp:td></xp:tr>

<xp:tr><xp:td style="text-align:center">

  <xp:panel styleClass="lotusList" style="margin:2px 10px">

    <xp:link escape="true" text="Upload" id="Send" outerStyleClass="lotusBtn lotusBtnAction">

      <xp:eventHandler event="onclick" submit="true" refreshMode="complete">

        <xp:this.action><![CDATA[#{javascript:

alert(“Send”);

var cmt=getComponent(“Comments”);

if(cmt) {

cmt.value=Ticket.getItemValueString("Comment");

} else {

print("** dlgWFNote 'Comment' not found! **");

} }]]></xp:this.action>

        <xp:this.script>

          <xp:executeClientScript><![CDATA[alert("Send");]]></xp:executeClientScript>

        </xp:this.script>

      </xp:eventHandler>

    </xp:link>

    <xp:text value="&#160;-&#160;" />

    <xp:link escape="true" text="Cancel" id="Cancel" outerStyleClass="lotusBtn lotusBtnAction">

      <!--xp:eventHandler event="onclick" submit="true" refreshMode="complete">

        <xp:this.script>

          <xp:executeClientScript><![CDATA[alert("Cancel");]]></xp:executeClientScript>

        </xp:this.script>

      </xp:eventHandler-->

    </xp:link>

  </xp:panel>

</xp:td></xp:tr>

</xp:table>

</xp:view>

Subject: BUMP

  • Nothing? No one uses dojo dialogs or is everyone too mad at me to answer?

  • I figured out the Cancel was triggered because it was a duplicate ID. I made them unique and now it doesn’t trigger the “Cancel” button every time I “load” the dialog.

  • But it’s still not “modal”. I see the dialog appear, then it instantly vanishes and the page repaints. It doesn’t reload … I’d see data on the Domino console if that happened (or i should). It’s impossible to interact with the dialog because it never hangs around long enough to do that…