Search code examples
javascriptxpageslotus-domino

Displaying responses as embedded view on the parent document of an XPages


I have two forms, Organisation and Contact. Contact is a response to Organisation, and each form has an XPage where the form can be filled in, saved etc. contact is also displayed under Org. embedded view using dataTable. On org.xsp, I have a button with 2 events. The first save the org.xsp. The second is a "Create Response Document" event which creates a new response with the parent ID being the current org document, and sends the user to contact.xsp.

<xp:button value="Create Contact" id="button3">
                <xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="dialog1">
                    <xp:this.action>
                        <xp:actionGroup>
                            <xp:actionGroup>

                                <xp:saveDocument var="orgDoc"></xp:saveDocument>
                                <xp:createResponse name="/contact.xsp"
                                    parentId="#{javascript:orgDoc.getDocument().getUniversalID()}">
                                </xp:createResponse>
                            </xp:actionGroup>
                        </xp:actionGroup>
                    </xp:this.action>
                </xp:eventHandler>
            </xp:button>

On contact.xsp, I have a button with 2 events. The first save the contact.xsp. The second is a "openPage" event which sends the user to org.xsp. with the document ID being:

contactDoc.getDocument().getParentDocumentUNID()

When saving the new contact.xsp everything work fine, am redirected to the right parent document(org.xsp) and the response document(contact.xsp) is displayed in a dataTable on org.xsp.

In the dataTable i have a link that will enable me to open and edit contact.xsp:

 <xp:link escape="true" id="link1">
    <xp:this.text><![CDATA[#{javascript:contactView.getColumnValue("contactName")}]]>  </xp:this.text>
    <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
        <xp:this.action>
            <xp:openPage name="/contact.xsp" target="openDocument"documentId="#{javascript:orgDoc.getDocument().getParentDocumentUNID()}">
            </xp:openPage>
        </xp:this.action>
    </xp:eventHandler>
</xp:link>

After i might have edit the contact.xsp now to save with the below code i am redirected to a wrong parent document or to a empty document.

     <xp:button value="Save Contact" id="button11">
                <xp:eventHandler event="onclick" submit="true" refreshMode="complete" immediate="false" save="true">
                    <xp:this.action>
                        <xp:actionGroup>
                            <xp:saveDocument var="contactDoc"></xp:saveDocument>
                            <xp:openPage name="/org.xsp" target="editDocument">
                                <xp:this.documentId><![CDATA[# {javascript:contactDoc.getDocument().getParentDocumentUNID()
    }]]></xp:this.documentId>
                            </xp:openPage>
                        </xp:actionGroup>
                    </xp:this.action>
                </xp:eventHandler>
            </xp:button>

How can i solve this or what is the write document id to use?

contactDoc.getDocument().getParentDocumentUNID()

Solution

  • You are opening the wrong document in the link on your dataTable. You want to open the response document but instead you are opening currentDocument.getDocument().getParentDocumentUNID() which is the parent of the Organiation document (which doesn't exist as far as I understand your data model).

    Instead you want to use the document id of the response document in question. Assuming that your dataTable uses a var called responseDoc you should do the following:

    <xp:link escape="true" id="link1">
        <xp:this.text><![CDATA[#{javascript:contactView.getColumnValue("contactName")}]]>  </xp:this.text>
        <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
            <xp:this.action>
                <xp:openPage name="/contact.xsp" target="openDocument" documentId="#{javascript:responseDoc.getUniversalID()}">
                </xp:openPage>
            </xp:this.action>
        </xp:eventHandler>
    </xp:link>
    

    Update: I see that you have updated your question. As far as I understand your problem is not creating the response document in the first place but rather that opening the response document from the dataTable and then saving the response document takes you to a wrong parent document. Please see my answer above on using the correct document id when going back to the parent document.