I want to auto update datatable (on client) when user is idle. I'm using Primefaces 3.5 with glassfish and my idea was following:
I've boolean autoUpdate
variable in bean. And user can turn on/off the auto update.
I created two components: p:poll
and p:idleMonitor
.
The idleMonitor
has two events, which trigger the update
<p:ajax event="idle" oncomplete="myPoll.start();" />
<p:ajax event="active" oncomplete="myPoll.stop();" />
This part is ok. The problem is, how to disable idleMonitor
when autoUpdate
is set to False
? When I do
<h:panelGroup id="updatePanel" rendered="#{cc.attrs.bean.autoUpdate}">
....
</h:panelGroup>
it works only if I start with autoUpdate = false
and I can switch the mode only once. Once it's rendered it can't be changed. I've also tried
<p:ajax event="idle" oncomplete="#{cc.attrs.bean.autoUpdate ? 'myPoll.start();' : ''}" />
but it didn't work neither. The #{cc.attrs.bean.autoUpdate}
is never changed. Even I'm calling upadte on it and I can see the variable changed on another place.
So, my question is: Is there any way how to disable idleMonitor, after it was rendered? Or what is the better solution for optional periodical update for idle's user?