Updating multiple components with poll

UI Components for JSF
Post Reply
dparasam
Posts: 9
Joined: 17 Nov 2016, 00:20

18 Jan 2018, 17:51

I have a page which has several components that need to be updated periodically. I am using a single PrimeFaces poll component with a listener that updates all components. The markup looks like this:

Code: Select all

<h:form id="pollForm">
    <prime:poll id="poll" interval="5" listener="#{myBean.updateAll}" async="true"/>
</h:form>


The updateAll method updates data for desired components in separate threads. Each of those updates may take varying amounts of time, some taking over the poll interval of 5 seconds.

Now if I specify the "update" attribute for poll, the components are not updated until a poll request gets a 200OK response, which may take longer than the poll interval if any of the update threads takes longer (I guess this is the expected behavior).
To make the updates more dynamic, I tried using PrimeFaces push to send a notification to update the components as soon as an update thread finishes. The markup for the corresponding socket looks like this:

Code: Select all

<h:form id="socketForm">
    <prime:socket id="myBeanSocket" channel="/myBean">
        <prime:ajax event="message" update=":myBeanForm:myComponent"/>
    </prime:socket>
</h:form>
However I still notice that this doesn't seem to help. The components are updated only when a 200OK response is obtained for a poll.
Any thoughts on why the updates could be delayed, even when using push?

Is there a recommendation on how to do periodic polling to update multiple components on single page?
Also I notice that PrimeFaces push with Sockets doesn't seem to work well when more than one socket is placed on a single page?

Environment:
Glassfish: 4.1
PrimeFaces: 6.1
Atmosphere runtime: 2.4.9
JSF API (javax.faces-api): 2.2

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

19 Jan 2018, 14:25

I know this is not great but i think it solves your problem but why not have 2 pollers. 1 to perform the Server Side updates and 1 to perform the Client side updates at different intervals. For example:

Code: Select all

// server just runs the call to update the background threads
<prime:poll id="pollServer" interval="5" listener="#{myBean.updateAll}" async="true" immediate="true" process="@this"/>

// client just runs every 5 seconds repainting the components you want to update
<prime:poll id="pollClient" interval="5" async="false" immediate="true" process="@this" update="component1 component2 etc...." />
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 15 guests