1
votes

I have a list of products (created using a repeat control) and wish to click on a particular product and bring up a dialog with further information about that particular product. I don't really want to generate dijit.dialog thing for every single product on that page, so how can I do this dynamically possibly using AJAX and partial refresh.

A similar non xpages example can be seen here: http://www.replacementkeys.co.uk/window?dir=asc&limit=12&mode=grid&order=position - where you hover over an image and a quick view button comes up, which then dynamically loads the content for that product.

Any ideas would be truly appreciated.

2

2 Answers

4
votes

We build the dialog outside the repeat control and then the action that launches or shows it also sets a viewScope variable that is used UNID for the data source in the dialog. Just make sure you refresh the contents of the dialog as you open it...

<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:this.data>
    <xp:dominoView var="promptView" viewName="dlgBoxes">
    </xp:dominoView>
</xp:this.data>
<xp:panel>
    <xp:repeat id="repeat1" rows="30" value="#{promptView}" var="promptEntry">
        <xp:panel tagName="div">
            <xp:text escape="true" id="computedField1" value="#{promptEntry.dlgName}">
            </xp:text>
            &#160;
            <xp:button value="details" id="button1">
                <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
                    <xp:this.action><![CDATA[#{javascript:
                        var pe:NotesViewEntry = promptEntry;
                        viewScope.put("dlgDocUnid", pe.getUniversalID());
                        getComponent("dialog1").show();
                    }]]></xp:this.action>
                </xp:eventHandler>
            </xp:button>
        </xp:panel>
    </xp:repeat>
</xp:panel>

<xe:dialog id="dialog1" keepComponents="false" partialRefresh="true">
    <xe:this.title><![CDATA[#{javascript:
        var unid = viewScope.get("dlgDocUnid");
        if(!unid) return "";
        var doc:NotesDocument = database.getDocumentByUNID(unid);
    return doc.getItemValueString("dlgName");}]]></xe:this.title>
    <xp:panel>
        <xp:this.data>
            <xp:dominoDocument var="dlgDoc" formName="dlgBox" action="openDocument">
                <xp:this.documentId><![CDATA[#{javascript:viewScope.get("dlgDocUnid");}]]></xp:this.documentId>
            </xp:dominoDocument>
        </xp:this.data>
        <xp:text escape="true" id="computedField2" value="#{dlgDoc.Title}">
        </xp:text>
        <xp:br></xp:br>
        <xp:br></xp:br>
        <xp:text escape="true" id="computedField3" value="#{dlgDoc.dlg}">
        </xp:text>
    </xp:panel>
</xe:dialog>
</xp:view>

Happy coding

/Newbs

2
votes

You can combine your repeat control with the Extension Library dialog control in order to be able to launch a dialog when the user clicks on the individual row. Chris Toohey has created an excellent article called Popup Dialog Forms from Views in XPages that demonstrates this.