我想刷新客户端Javascript触发的重复控制。为了使它有趣,我的数据源是一个JDBC查询,这就是为什么我不只是进行局部刷新。 我见过有关使用XHR请求执行此操作的页面,但我看不到如何刷新JDBC数据以捕获新信息。 我可以使用旧数据刷新重复控制,而不是新数据。XPages - 刷新客户端的JDBC数据
我看到了Repeat control refresh error 它谈到可能需要超时,因为运行时不知道新数据。 我手动更改数据库中的某些内容并等待一分钟后运行XHR,仍然有旧信息。
我可以更新RPC调用中的变量(jdbcPendingSummary)吗?如果不能,我可以调用回服务器来触发CSJS函数内部的刷新吗?
<xp:this.data>
<xe:jdbcQuery connectionName="testDB"
sqlQuery="EXEC ptoGetPendingRequests #{sessionScope.userID}"
var="jdbcPendingSummary" />
</xp:this.data>
<xe:jsonRpcService id="ptoRPC" serviceName="ptoRPC">
<xe:this.methods>
<xe:remoteMethod name="createNewRequest">
<xe:this.script><![CDATA[
javaBeanObject.ptoCreateRequest(#{sessionScope.userID}, startDate, endDate, comment, d1,....,d15);
// Can I update the datasource var here?
]]></xe:this.script>
<xe:this.arguments>
<xe:remoteMethodArg name="startDate" type="string"></xe:remoteMethodArg>
..........
<xe:remoteMethodArg name="d15" type="number"></xe:remoteMethodArg>
</xe:this.arguments>
</xe:remoteMethod>
</xe:this.methods>
</xe:jsonRpcService>
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[
function createNewRequest(startDateID, endDateID, commentID, hiddenDivID, requestID) {
ptoRPC.createNewRequest(dojo.byId(startDateID).value, dojo.byId(endDateID).value, ........).addCallback(function(response) {
// ????? Refreshes the Repeat Control, but has the stale data.
setTimeout(
function() {
XSP.partialRefreshGet(requestID, {onComplete: function(responseData) { } })
// Or how about updating the datasource var here?
}, 8000);
});
}
]]></xp:this.value>
</xp:scriptBlock>
我已经修改了你的榜样,它的工作原理提取新数据 - 我无法让PRC与您列出的数据刷新一起工作。这种方式确实会导致发送一对额外的k数据 ,但它并不可怕。 不知道怎么回事,但在行尾有2个空格不给我一个换行符 ' XP:executeClientScript> XP:此.script> xp:eventHandler>' –
anotherBob
2013-03-21 17:52:08
不知道我在这里了解换行问题。它是在这个网站上还是在Designer内部? – andrejusc 2013-03-22 15:17:19
我在评论说我无法格式化我在评论中粘贴的代码(所以堆栈溢出,而不是设计器)。根据帮助页面,如果您做了2个空格,它应该放入一个换行符。 – anotherBob 2013-03-22 19:59:25