如何正确地对 Xpages 中的多个项目进行部分刷新 [英] How to do a partial refresh of multiple items in Xpages correctly

查看:30
本文介绍了如何正确地对 Xpages 中的多个项目进行部分刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了许多关于对多个元素进行部分刷新的博文,但我似乎无法让它发挥作用.

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.

我制作了一个玩具"示例,一个包含两个字段和一个按钮的 Xpage.这两个字段都绑定到 sessionScope 计数器.该按钮会增加计数器并在包含面板上进行部分刷新.

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.

我想对第一个字段进行部分刷新,该字段不在面板中[在我真正的 Xpage 中,两个字段在表单上相距很远.

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>

阅读 Knut 的链接并使其生效.我对按钮的事件处理程序进行了更改并且它起作用了.代码如下:

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>

推荐答案

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

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

这篇关于如何正确地对 Xpages 中的多个项目进行部分刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆