I have a rather long, tabbed XPage form to be populated by visitors, and I'd like to auto-save in the backend every few minutes.
The entire form represents a managed bean, and I can populate/save a Domino document from the bean values using a button manually just by calling...
portfolio.save(sessionScope.unid,false)
I located this excellent post by Jeremy Hodge (great how the older tips stand the test of time!) that explains the technique...
http://xpages.info/XPagesHome.nsf/Entry.xsp?documentId=88065536729EA065852578CB0066ADEC
I then found a forum response from Paul Calhoun that describes the use of the technique with a timer to fire off regular document saves...
I have implemented the technique on my XPage, but the SSJS simply isn't firing. I've even placed 'onStart' and 'onComplete' events to validate everything is working as expected. The counter works, the console shows the timer and the alerts appear every 5 seconds or so... but the SSJS simply isn't initiated.
My eventHandler that does the work...
<xp:eventHandler event="onfubar" id="autoSave" submit="false">
<xp:this.action><![CDATA[#{javascript:portfolio.save(sessionScope.unid,false);}]]>
</xp:this.action>
</xp:eventHandler>
... and the event handler that triggers the regular save (yes, I know that I've butchered the 'executeOnServer' command and manually added the additional parameters - just trying to isolate the issue)...
<xp:eventHandler event="onClientLoad" submit="false">
<xp:this.script><![CDATA[
var executeOnServer = function () {
// must supply event handler id or we're outta here....
if (!arguments[0])
return false;
// the ID of the event handler we want to execute
var functionName = arguments[0];
// OPTIONAL - The Client Side ID that you want to partial refresh after executing the event handler
var refreshId = (arguments[1]) ? arguments[1] : "@none";
var form = (arguments[1]) ? XSP.findForm(arguments[1]) : dojo.query('form')[0];
// OPTIONAL - Options object contianing onStart, onComplete and onError functions for the call to the
// handler and subsequent partial refresh
var options = (arguments[2]) ? arguments[2] : {};
// Set the ID in $$xspsubmitid of the event handler to execute
dojo.query('[name="$$xspsubmitid"]')[0].value = form.id + ':' + functionName;
XSP._partialRefresh("post", form, refreshId, options);
}
var x = 0;
var form = document.forms[0];
t = new dojox.timing.Timer(3600);
t.onTick = function() {
x+=1;
console.info(x);
if(x > 4){
x = 0;
console.info("reset");
executeOnServer('autoSave','@none',{
onStart: function() { alert('starting!'); },
onComplete: function() { alert('complete!'); },
onError: function() { alert('DANGER WILL ROBINSON!'); }
});
}
}
t.onStart = function() {
console.info("Starting timer");
}
t.start();]]></xp:this.script>
</xp:eventHandler>
I know that I must be missing something, and I'm probably staring straight at it, but I simply can't figure out where I've gone wrong.
Thanks very much for any insight into the issue (and a point in the right direction!).