0

I am using JSF with Primefaces and using poll to update a table periodically. The following code shows a simplified version of my current code:

<h:form id="form">
    <p:datatable id="customerTable" var="customer" value="#{dashboard.customers}">
        [...]
    </p:datatable>

    <p:poll interval="5" update="form:customerTable" />
</h:form>

The update is done every 5 seconds as expected. But the problem is that the customerTable seems to be loaded several times per update. My code in the backing bean which is called by the #{dashboard.customers} is as follows:

public List<Customer> getCustomers()
{
    LOG.debug("TEST");
    return customerService.loadCustomerList();
}

When I reload the page getCustomers() is called once, but via the polling it is called several times. Why is it called so often? Is the polling defined incorrectly?

millhouse
  • 9,817
  • 4
  • 32
  • 40
Georg Leber
  • 3,470
  • 5
  • 40
  • 63
  • 1
    I'm surprise that the `getCustomers` method is only called once without polling. How are you sure? Also read the excellent explanation of BalusC about [Why JSF calls getters multiple times](http://stackoverflow.com/a/2090062/913543). – LaurentG Feb 12 '14 at 09:13
  • Thought about this lifecycle handling, but as it was called only once on page reload seemingly, I assumed that I implemented the polling mechanism wrong. Thanks for the link. I need to change my code accordingly :) – Georg Leber Feb 12 '14 at 09:16

0 Answers0