One problem I have with web apps is getting view to refresh when another user updates/creates docume
Domino Development / XPagesShow Correct Answer...Hide Answer...
John, the solution here is buried withing the XSP object. If you are using 8.5.1, then the following sample will work. If you are using 8.5, then look at the uncompressed version of xspClientDojo.js at the firePartialRefreshEvent procedure (or get upgraded to 8.5.1 'cause it's alot easier). This code sets up a simple javascript setInterval() that updates the refreshPanel from the server by executing an XSP.partialRefreshPost, passing it two parameters, the first being the ID of the object you want to refresh, the second parameter is an object that contains information about the refresh itself. For this post, the object could be an empty object ( {} ), but I included the identifiers for the three client-side events. These events get called before (onStart), after (onComplete), or when there is an error (onError). You can assign functions to each of those in the object. The scope of the events is the object itself, so you can add additional variables to the object if you need to reference other items as well.
As Always: Disclaimer
: IBM Lotus Notes/Domino and Lotus Notes Traveler 8.5.1 is prerelease
code and there are no guarantees from IBM that the functionality
presented will be in the final shipping product.
Here's the code:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:panel id="refreshPanel">
<xp:text escape="true" id="computedField1"
value="#{javascript:@Now()}">
<xp:this.converter>
<xp:convertDateTime type="both" timeStyle="long"></xp:convertDateTime>
</xp:this.converter>
</xp:text></xp:panel>
<xp:scriptBlock id="scriptBlock1">
<xp:this.value>
<![CDATA[
setInterval(function() {
XSP.partialRefreshPost("#{id:refreshPanel}", {
onStart: null,
onComplete: null,
onError: null
})
}, 1000)
]]>
</xp:this.value>
</xp:scriptBlock>
</xp:view>