本文介绍了几秒钟后需要重新加载 XPage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让 XPage 在 1 秒后重新加载,但无法找出执行此操作的代码.有没有人有关于如何在 XPage 中执行此操作的示例?

I am trying to get an XPage to reload after 1 second but can't figure out the code to do it. Does anyone have an example on how to do this in XPages?

推荐答案

在客户端 JavaScript 代码块 <xp:scriptBlock 中使用 JavaScript 的 setTimeout() 函数执行一秒后重新加载 (1000女士):

Use JavaScript's setTimeout() function in Client Side JavaScript code block <xp:scriptBlock to execute a reload after a second (1000 ms):

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:scriptBlock id="scriptBlockReload">
        <xp:this.value>
        <![CDATA[
            setTimeout(function() {
                 location.reload();
            }, 1000)
        ]]>
        </xp:this.value>
    </xp:scriptBlock>
    <xp:text escape="true" id="computedField1">
        <xp:this.value><![CDATA[#{javascript:new Date().getTime()}]]></xp:this.value>
    </xp:text>
</xp:view>

如果您只想刷新 XPage 的一部分而不是完全重新加载它,您可以替换

In case you just want to refresh a part of your XPage instead of reloading it completely you can replace

location.reload();

XSP.partialRefreshGet("#{id:computedField1}", {})

它会在一秒后刷新一次计算字段1.由您指定哪种 id 取决于您.它可以是包含 XPage 的多个甚至所有组件的面板的 ID.

It will refresh computedField1 once after a second. It is up to you what kind of id you specify. It could be the id of a panel which includes several or even all components of your XPage.

这篇关于几秒钟后需要重新加载 XPage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-26 05:45