I can't really say that I think this is a good idea, but it works
Here is the complete xsp source of a simple timer that saves the "document" ever 10-20 seconds
It uses Jeremy Hodges csjs eventHandler routine in combination with a dojo timer
I tested it in FF and Chrome and worked fine.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.resources>
<xp:dojoModule
name="dojox.timing"></xp:dojoModule>
</xp:this.resources>
<xp:this.data>
<xp:dominoDocument
var="document1"
formName="StoredFormData">
</xp:dominoDocument>
</xp:this.data>
<xp:eventHandler event="onfubar" id="autoSaveDoc" submit="false">
<xp:this.action>
<xp:saveDocument></xp:saveDocument>
</xp:this.action>
</xp:eventHandler>
<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 > 10){
x = 0;
console.info(x);
console.info("reset");
executeOnServer('autoSaveDoc');
}
}
t.onStart = function() {
console.info("Starting timer");
}
t.start();]]></xp:this.script>
</xp:eventHandler>
<xp:panel id="dataFields"><xp:table>
<xp:tr>
<xp:td>
<xp:label value="First name:" id="firstName_Label1" for="firstName1">
</xp:label>
</xp:td>
<xp:td>
<xp:inputText value="#{document1.FirstName}" id="firstName1" defaultValue="Bob">
</xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label value="Last name:" id="lastName_Label1" for="lastName1">
</xp:label>
</xp:td>
<xp:td>
<xp:inputText value="#{document1.LastName}" id="lastName1" defaultValue="Maher">
</xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td></xp:td>
<xp:td>
<xp:button value="Submit" id="button1">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete" immediate="false" save="true" id="eventHandler1">
</xp:eventHandler>
</xp:button>
</xp:td>
</xp:tr>
</xp:table
></xp:panel
><xp:this.navigationRules
><xp:navigationRule
outcome="xsp-success" viewId="/StoredFormView.xsp"></xp:navigationRule
></xp:this.navigationRules
></xp:view
>