我正在尝试使用扩展库组件 Remote Service ( xe:jsonRpcService
)。我从这里和这里得到了一些提示。基本上我正在尝试使用 RPC 保存文档。问题是文档被保存,但它没有保存 XPage 上存在的任何字段。下面是示例 XPage 代码:
<?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:this.data>
<xp:dominoDocument var="document1" formName="Test"></xp:dominoDocument>
</xp:this.data>
<xe:jsonRpcService id="jsonRpcService1" serviceName="service">
<xe:this.methods>
<xe:remoteMethod name="saveDoc">
<xe:this.script><![CDATA[print(">> " + getComponent("inputText1").getValue());
document1.save();
return true;]]></xe:this.script>
</xe:remoteMethod>
</xe:this.methods>
</xe:jsonRpcService>
<xp:br></xp:br>
<xp:inputText id="inputText1" defaultValue="testValue" value="#{document1.testField}"></xp:inputText>
<xp:br></xp:br>
<xp:button value="Save" id="button1">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[var deferred = service.saveDoc();
deferred.addCallback(
function(result) {
alert(result);
}
);]]></xp:this.script>
</xp:eventHandler>
</xp:button>
</xp:view>
我在这里所做的是,我创建了远程服务 ( service
),我在其中保存了当前文档 ( document1
)。它保存文档但不将值保存在inputText1
. 此外,当我尝试打印它的值时,inputText1
它会显示在控制台上,但它没有被保存。
这是正确的方法吗?或者我在这里错过了什么。还有什么情况下使用xe:jsonRpcService
是合理的?