Search code examples
xpageslotus-domino

xpages, save all documents in a repeat panel


I'm trying out a simple xpage that fetches a parent document (form fParent) and a few child documents (form fChild) via view vChildren. I can get the children as read only via a normal view control but these are read-only and I'd like to bind the children to documents so the save/submit button makes changes to both the parent and child documents.

In the repeat control, I'm binding the variable rowData to a DocumentCollection object which I'm assuming is iterated over and returns a Document object for each item (this seems to work as the xpage displays the correct number of custom controls). I understand from the HCL documentation that in order for the save action to be able to make changes to the child documents I need to add a document data source which I have done in the custom control.

The issue I have is that document2 in the custom control is picking up the parent form data and not the child form data (the note IDs for each child are the same as the parent which makes me think this is the case).

What am I doing wrong? Code below and thanks in advance.

xPage for the parent

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xc="http://www.ibm.com/xsp/custom">
    <xp:this.data>
        <xp:dominoDocument formName="fParent" var="document1" />
        <xp:dominoView 
            var="view1" viewName="vChildren"
            categoryFilter="#{document1.Key}">
        </xp:dominoView>
    </xp:this.data>
    
    Name
    <xp:inputText id="inputText2" value="#{document1.Name}"></xp:inputText>
    <xp:br></xp:br>
    
    Key&#160;
    <xp:text escape="true" id="computedField1" value="#{document1['Key']}">
    </xp:text>
    <xp:br></xp:br>
    
    <xp:repeat id="repeat1" rows="30" var="rowData">
        <xp:this.value><![CDATA[#{javascript:
        var key = currentDocument.getItemValueString("key");
        return database.getView('vChildren').getAllDocumentsByKey(key);}
        ]]>
        </xp:this.value>
        <xc:ccChildDoc></xc:ccChildDoc>
    </xp:repeat>
    
    <xp:button id="button1" value="Save" save="true" type="submit"></xp:button>
</xp:view>

Custom control for each child document

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" binding="#{rowData}">
    <xp:this.data>
        <xp:dominoDocument 
            formName="fChild" var="document2"
            action="editDocument" computeWithForm="both"
            documentId="#{javascript:rowData.getNoteID();}">
        </xp:dominoDocument>
    </xp:this.data>
    <xp:panel>
        Note id:&#160;
        <xp:text escape="true" id="computedField1" value="#{javascript:document2.getNoteID();}">
        </xp:text>
        <xp:br></xp:br>

        Comment&#160;
        <xp:inputText id="inputText1" value="#{document2.Comment}" readonly="false">
        </xp:inputText>
        <xp:br></xp:br>

        Field2&#160;
        <xp:inputText id="inputText2" value="#{document2.Field2}" readonly="false">
        </xp:inputText>
        <xp:br></xp:br>
        <hr />
    </xp:panel>
</xp:view>

Solution

  • Try adding ignoreRequestParams="true" to your data source for the child document.

    This parameter tells XPages to ignore the documentId parameter in the URL for the child document data source and the child data source should then use documentId="#{javascript:rowData.getNoteID();}".