简体   繁体   中英

current-dateTime() value is not updating on page-refresh event

I set the value of an instance to 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 !

Later I use this instance value to make GET request calls to a resource and pass this updated instance value as a parameter.

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

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. Is there some other way I can get the updated dateTime on page-refresh event ?

With XSLTForms you can call Javascript functions on XPath expressions on client side, this way:

 <xf:setvalue ref="instance('noCache')/val" value="getXMLDate()" ></xf:setvalue> 

And write the getXMLDate() function in your HTML:

<script>
function gwtXMLDate(){
  var d = new Date();
  return d.toISOString();
}
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM