Friday, 25 March 2011

Automatically Refreshing an XPage

I've been working on a dashboard style application recently for which users will typically open an XPage and leave it sitting in the background until they flick it open for an update.

The problem with this is that the screen does not automatically refresh and it isn't always easy to our poor users to remember to hit F9 when they want to update.

Therefore, I have made use of the following 2 solutions.  One to reload and entire page and another to reload a particular panel / ID on the XPage via a partial refresh.  Both of these are on a timer setting.

Full Update
<
script type="text/javascript">
setTimeout(function() { window.location.reload(); }, 180000);
</script>
Partial Refresh
<
xp:scriptBlock id="scriptBlock2">
<xp:this.value>
<![CDATA[
setInterval(function() {
XSP.partialRefreshPost("#{id:<ID of panel / ID>}", {
onStart: null,
onComplete: null,
onError: null
})
}, 180000)
]]>
</xp:this.value></xp:scriptBlock>

1 comment:

  1. Hi,
    May i know where should i put this script in xPage in order to automatically refresh? Thanks

    ReplyDelete