2
votes

I have read many of the blog posts on doing a partial refresh on more than one element, but I cannot seem to get it to work.

I made a "toy" example, an Xpage with two fields and one button. Both fields are bound to a sessionScope counter. The button increments the counter and does a partial refresh on the containing panel.

I want to do a partial refresh on the first field, which is not in the panel [in my real Xpage the two fields are very far apart on the form.

Tried many different things to get this to work, but none worked. Is it even possible to do this?

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
    xmlns:xe="http://www.ibm.com/xsp/coreex"
    xmlns:xc="http://www.ibm.com/xsp/custom"
    style="background-position:center left"
    xmlns:on="http://www.openntf.org/domino/xsp" viewState="nostate"
    xmlns:debug="http://www.openntf.org/xsp/debugtoolbar">

    First Var<br></br>

    <xp:text escape="true" id="computedField1" value="#{sessionScope.number}">
    </xp:text>

        <br></br>
        <xp:br></xp:br>
        <br></br>

    Second Var<xp:panel id="pnl1">
        <xp:text escape="true" id="computedField2" value="#{sessionScope.number}">
        </xp:text>
        <br></br>
        <br></br>
        <xp:button value="Label" id="button1">
            <xp:eventHandler event="onclick" submit="true"
                refreshMode="partial" refreshId="pnl1" execMode="partial"
                execId="pnl1">
                <xp:this.action><![CDATA[#{javascript:var t = sessionScope.number + 1;
sessionScope.number = t;}]]></xp:this.action>
            </xp:eventHandler>
        </xp:button>
    </xp:panel>

</xp:view>

Read Knut's link and got this to work. I made a change to the event handler of the button and it worked. Here is the code:

            <xp:eventHandler event="onclick" submit="true"
                refreshMode="partial" refreshId="pnl1" execMode="partial"
                execId="pnl1">
                <xp:this.action><![CDATA[#{javascript:var t = sessionScope.number + 1;
sessionScope.number = t;}]]></xp:this.action>
                <xp:this.onComplete><![CDATA[XSP.partialRefreshPost("#{id:computedField1}");]]></xp:this.onComplete>
            </xp:eventHandler>
1
I had read that but couldn't figure it out. Read it carefully a few more times and now I get it. I am updating my code above for the benefit of others. Post this as an answer and I will give you credit. Thanks!Bryan Schmiedeler

1 Answers