2
votes

I have a repeat control with a dominoview as datasource, which shows main documents.

To each entry in the repeat the user can make comments, which are saved with reference to the doc/entry. When the user saved a comment, I use the universalID of the doc as reference. I get this unID from a column value of the underlying dominoview.

We are struggling with changes in the underlying view (new docs are created, deleted from other users). The xpage is - of course - still showing the situation of the page load, but when you do sth in the repeat (add comments), the rowindex is referencing to the backend view, not to the shown data in the xpage.

Maybe an example helps to make it clear:

User A opens the xpage, reads it (...?), then decides to make a comment to entry/doc No 3. Meanwhile User B has created another main doc (so that in the backend view, the position of the entry for user A has moved to row 4. Now when user A saves his comment, it is referenced to the former row 2 document.

Is there a way to prevent this lookup?

thx for any help, Uwe

1

1 Answers

0
votes

Don't use the index.

Use underlying repeat row's document instead.

Define a variable in repeat e.g. var="row" and get the document with row.getDocument().
This way you can be sure that the correct document gets changed.

<xp:repeat
    id="repeat1"
    rows="30"
    value="#{view1}"
    var="row">
    ...
    <xp:button
        value="change document"
        id="button1">
        <xp:eventHandler
            event="onclick"
            submit="true"
            refreshMode="complete">
            <xp:this.action><![CDATA[#{javascript:
                var doc = row.getDocument();
                doc.replaceItemValue("comment", "my comment");
                doc.save();
        }]]></xp:this.action>
        </xp:eventHandler>
    </xp:button>
</xp:repeat>