<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:inputText id="inputText"></xp:inputText>
<xp:button value="Post" id="button1">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[var s = dojo.byId("#{id:inputText}").value;
alert("Post " + s);
var deferred = logService.log(s);
deferred.addCallback(
function(result) {
alert("Done");
}
);
]]></xp:this.script>
</xp:eventHandler>
</xp:button>
<xe:jsonRpcService id="jsonRpcService1" serviceName="logService">
<xe:this.methods>
<xe:remoteMethod name="log">
<xe:this.script><![CDATA[var doc = database.createDocument();
doc.replaceItemValue("Form", "Log");
doc.replaceItemValue("Text", textParam);
doc.save();]]></xe:this.script>
<xe:this.arguments>
<xe:remoteMethodArg name="textParam"></xe:remoteMethodArg>
</xe:this.arguments>
</xe:remoteMethod>
</xe:this.methods>
</xe:jsonRpcService>
</xp:view>