- Helpers
- Poll
Poll
Poll lets you repeat a server action or simply render/execute any component on a set interval with an optional delay before the first call is made. The Widget API provides methods to stop and start the poller as well.
Tip: Make sure the Ajax request doesn't update the poller itself, as that would result in the intial delay being applied to each poll interval. For this reason, the default
render
value is null
and the default execute
value is
@this
.
Example
Documentation
<h:form id="pollForm">
<h:outputText value="Server time: #{controller.now}" id="time"/>
<t:poll interval="1000" widgetVar="poller" render="time"/>
</h:form>
<div>
<button class="success" onclick="TW('poller').start();">Start poller</button>
<button class="alert" onclick="TW('poller').stop()">Stop poller</button>
</div>
Poll lets you repeat a server action or simply render/execute any component on a set interval with an optional delay before the first call is made. The Widget API provides methods to stop and start the poller as well.
Info
Tag name | poll |
---|---|
Component type | io.tornadofaces.component.Poll |
Renderer type | io.tornadofaces.component.PollRenderer |
Attributes
Name | Description | Required |
---|---|---|
interval | The number of milliseconds between each poll. | true |
onload | Start the poller on DOM load. Defaults to true. | false |
delay | The number of milliseconds before the first poll. | false |
onload | Start the poller, optionally after the specified delay on DOM load. Defaults to true. | false |
action | The action to call every time while interval is reached | false |
render | Space separated list of components to render after ajax. Defaults to null". | false |
execute | Space separated list of components to execute on ajax. Default "@this". | false |
oncomplete | JavaScript callback triggered before the AJAX request is sent | false |
oncomplete | JavaScript callback triggered after AJAX response has arrived | false |
onsuccess | JavaScript callback triggered after DOM update based on AJAX request | false |
rendered | Should this component be rendered? | false |
Client Side API
Widget: TornadoFaces.widget.Poll
Method | Params | Return type | Description |
---|---|---|---|
start() | boolean | Start the poller. Return true if the poller was started, false if the poller was already running. | |
stop() | boolean | Stop the poller. Return true if the poller was stopped, false if the poller was not running. |