Ajax refresh timer of widgets

Ajax refresh timer of widgets

  

Is there a way to periodically refresh a widget (webblocks)

if so, how?


I'm not sure if this is what you're after, but there's a setInterval javascript function that can be used to that effect.

In the following example RefreshBt.Id is the ID of a button that triggers an action with an AJAX refresh for the desired element. Site.RefreshPooling is the refresh interval, in seconds.

<script type='text/javascript'>
 
function UpdateMessages(id)
{
  document.getElementById('" + RefreshBt.Id + "').click();
  return false;
}
 
setInterval('UpdateMessages()', " + Site.Refresh_Pooling*1000 + ");
</script>
<script type='text/javascript'>
function UpdateMessages(id)
{
  document.getElementById('" + RefreshBt.Id + "').click();
  return false;
}
 
setInterval('UpdateMessages()', " + Site.Refresh_Pooling*1000 + ");
</script>
"<script type='text/javascript'>
 
function UpdateMessages(id)
{
  document.getElementById('" + RefreshBt.Id + "').click();
  return false;
}
 
setInterval('UpdateMessages()', " + Site.Refresh_Pooling*1000 + ");
</script>"
"<script type='text/javascript'>
 
function UpdateMessages(id)
{
  document.getElementById('" + RefreshBt.Id + "').click();
  return false;
}
 
setInterval('UpdateMessages()', " + Site.Refresh_Pooling*1000 + ");
</script>"
João,

How can i implment javascript in the code? Under Screen's Extended properties\Web screen Javascript?

Dror



Hi Dror.

What are you trying to do, specifically?

What João said is the way to do it. He uses the code

<script type='text/javascript'>
function UpdateMessages(id)
{
  document.getElementById('" + RefreshBt.Id + "').click();
  return false;
}
 
setInterval('UpdateMessages()', " + Site.Refresh_Pooling*1000 + ");
</script>

probably in an unescaped expression (an Expression widget with the Escaped property set to false), from the syntax, where:

- UpdateMessages is the function to be called after each interval;
- Site.Refresh_Pooling is a site property where you set the interval (in seconds) after which the javascript function should be executed;
- RefreshBt.Id is, in this case, the widget's ID, since in his case he wants to click a button every X seconds.

Does this make it clearer for you?

Regards,

Paulo Tavares