How to do a partial refresh of multiple items in Xpages correctly

二次信任 提交于 2020-01-04 05:17:15

问题


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:


Use XSP.partialRefreshPost(): http://avatar.red-pill.mobi/tim/blog.nsf/d6plinks/TTRY-84B6VP



来源:https://stackoverflow.com/questions/37364137/how-to-do-a-partial-refresh-of-multiple-items-in-xpages-correctly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!