[英]current-dateTime() value is not updating on page-refresh event
I set the value of an instance to current-dateTime(). 我将实例的值设置为current-dateTime()。 I want to update this value on page-refresh event.
我想在页面刷新事件上更新此值。 So I have the following code:
所以我有以下代码:
<xf:action ev:event="page-refresh">
<xf:setvalue ref="instance('noCache')/val"><xsl:value-of select="current-dateTime()" /></xf:setvalue>
<!-- call to resource with new value-->
</xf:action>
This above code sets the instance value (dateTime) as the same which was at page-load ! 上面的代码将实例值(dateTime)设置为页面加载时的值!
Later I use this instance value to make GET request calls to a resource and pass this updated instance value as a parameter. 稍后,我使用该实例值对资源进行GET请求调用,并将此更新后的实例值作为参数传递。
Note: Using current-dateTime() to pass a parameter to the resource to avoid using cached resources (since couldn't find a way to generate random numbers 注意:使用current-dateTime()将参数传递给资源,以避免使用缓存的资源(因为无法找到生成随机数的方法
Seems like the problem I feel is that the xsl variable current-dateTime() is evaluated only on page-load and the same value is used for page-refresh. 我似乎感到的问题是,xsl变量current-dateTime()仅在页面加载时求值,并且相同的值用于页面刷新。 Is there some other way I can get the updated dateTime on page-refresh event ?
还有其他一些方法可以让我在页面刷新事件上获取更新的dateTime吗?
With XSLTForms you can call Javascript functions on XPath expressions on client side, this way: 使用XSLTForms,您可以通过以下方式在客户端的XPath表达式上调用Javascript函数:
<xf:setvalue ref="instance('noCache')/val" value="getXMLDate()" ></xf:setvalue>
And write the getXMLDate()
function in your HTML: 并在HTML中编写
getXMLDate()
函数:
<script>
function gwtXMLDate(){
var d = new Date();
return d.toISOString();
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.