1
votes

I have a panel inside a repeat control with a domino document data source attached to it:

<xp:panel id="RepeatPanel">
    <xp:this.data>
        <xp:dominoDocument
            var="doc"
            formName="TestForm"
            action="editDocument"
            documentId="#{javascript:viewScope.docId}"
            concurrencyMode="force">
        </xp:dominoDocument>
    </xp:this.data>

If a user makes field changes, I want to have a Cancel button that will do a partial refresh and reset all the fields back to what is stored on the existing Notes document. Is there a way I can accomplish this?

1

1 Answers

1
votes

Use option "set partial execution mode" execMode="partial":

<xp:button
    value="Cancel"
    id="button2">
    <xp:eventHandler
        event="onclick"
        submit="true"
        refreshMode="partial"
        refreshId="inputText1"
        execMode="partial">
    </xp:eventHandler>
</xp:button>

Only the button (button2) gets partially executed = updated to server. Not so the part which gets partially refresh (inputText1 in example). This way inputText1 value doesn't get sent to server and server renders this part with the former data.

You can find more information about this option in the book "Mastering XPages: A Step-by-Step Guide to XPages Application Development and ... Second Edition" at page 920 and following.

As an alternative, you can reset the fields within refresh area with the values from backend document. Use var docOld = document1.getDocument() to get the backend document with the "old" values and assign old values to current data sources fields with
document1.setValue("A", docOld.getItemValueString("A")):

    <xp:button
        id="buttonCancelRestore"
        value="Cancel Restore Values">
        <xp:eventHandler
            event="onclick"
            submit="true"
            refreshMode="partial"
            refreshId="panelRefresh"
            execMode="partial"
            execId="buttonCancelRestore">
            <xp:this.action><![CDATA[#{javascript:
                var docOld = document1.getDocument();
                document1.setValue("A", docOld.getItemValueString("A"));
                document1.setValue("B", docOld.getItemValueString("B"));
        }]]></xp:this.action>
        </xp:eventHandler>
    </xp:button>