【问题标题】:Xpages- how to automatically switch to next pager without human interaction?Xpages-如何在没有人工交互的情况下自动切换到下一页?
【发布时间】:2014-04-23 13:32:29
【问题描述】:

我想创建一个仪表板,在一个视图中显示 10 行记录,然后系统会在一定时间后自动切换到下一页。 无法在 XPages 中设置计时器以在下一页中自动切换寻呼机?如果是,您是否有任何示例代码可供参考?谢谢。

【问题讨论】:

    标签: xpages pager


    【解决方案1】:

    我前段时间创建了这样一个解决方案。也许它对你也有帮助。

    在 requestScope "rowsPerPage" 中,您可以定义每页应显示多少行,而在 requestScope "secondsPerPage" 中,您可以定义更改页面后的秒数。到达最后一页后,它会从第一页重新开始。

    <xp:this.beforeRenderResponse><![CDATA[#{javascript:
        requestScope.rowsPerPage = 4;
        requestScope.secondsPerPage = 2;
        if (viewScope.currentPage == null) {
            viewScope.put("currentPage", 1);
        } else {
            if (getComponent("viewPanel1").getRowCount() > viewScope.currentPage * requestScope.rowsPerPage) {
                viewScope.currentPage++;
                getComponent("viewPanel1").gotoNextPage();
            } else {
                viewScope.currentPage = 1;
                getComponent("viewPanel1").gotoFirstPage();
            }
        }
    }]]></xp:this.beforeRenderResponse>
    <xp:scriptBlock
        id="scriptBlockRefresh">
        <xp:this.value>
            <![CDATA[
                setInterval(function() {
                    XSP.partialRefreshPost("#{id:refreshPanel}", {})
                }, #{requestScope.secondsPerPage} *1000)
            ]]>
        </xp:this.value>
    </xp:scriptBlock>
    
    <xp:panel
        id="refreshPanel">
        <xp:viewPanel
            rows="#{javascript:try {requestScope.rowsPerPage} catch(e) {30}}"
            id="viewPanel1"
            xp:key="facet1"
            viewStyle="width:40em">
            <xp:this.facets>
                <xp:pager
                    partialRefresh="true"
                    layout="Group"
                    xp:key="headerPager"
                    id="pager1"
                    alwaysCalculateLast="true">
                </xp:pager>
            </xp:this.facets>
            <xp:this.data>
                <xp:dominoView
                    ...>
                </xp:dominoView>
            </xp:this.data>
            <xp:viewColumn
                ...>
            </xp:viewColumn>
            <xp:viewColumn
                ...>
            </xp:viewColumn>
        </xp:viewPanel>
    </xp:panel>
    

    【讨论】:

    • 我已经申请了上面的脚本,它运行良好。非常感谢。
    • 不客气。我为培训中心的公共屏幕开发了它,显示了当天所有预定的培训。它还会在转到下一页时立即显示视图的变化。
    【解决方案2】:

    我没有尝试过,但是您需要使用 CSJS 在预定义的秒数后使用 XSP.partialRefreshGet() 触发部分刷新,而这无法在服务器端完成。

    您可以以编程方式设置视图的“第一个”属性,获取或(在第一个实例中)设置 viewScope 变量。您需要确保它不会在页面刷新期间多次更新,可能通过设置 requestScope 变量并检查是否已设置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-23
      • 2011-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多