Dynamically update a primefaces table

Asked

Viewed 338 times

3

Hello, I am creating a java register with Primefaces. I have the following problem: I have a screen in xhtml and it carries the registered data, so far so good. The problem is when someone on another computer is accessing at the same time, you will not be able to see the new registration that was inserted, you will only be able to see if you have F5 on the page to update. Does anyone know how I do this implementation so that this problem is solved?

1 answer

2


Hello,

you can add an event that updates the table from both in so long.

<p:poll interval="10" listener="#{tabelaBean.carregarTabela}"
            update="idDaTabela"/>

with this function, your table will be updated every 10 seconds.

  • Okay, Raphão Torres, I’m having a hard time creating this method "load", I’m seeing how I do because I’m learning java too, thank you very much

  • Good night I managed to make it work, I used this public void method to loadNomeDaClasse(){ nameDaClasseDAO nameDaClasseDAO = new nameDaClasseDAO(); classname = classname.lister(); , using in view the <p:Poll interval="3" Listener="#{className" />

  • in my bean I used @Viewscoped. But now I have a doubt, I saw that he will be doing this every 3 seconds, this can an overload on the server and do the same to respond?

  • Glad you could work it out. Yes, you can overload the server. Change the interval for a longer time. I believe that there is no other way to do... Here in my company we have a screen with the result of sales that updates every 1 minute. But in your case, I think 20 seconds is good enough. Hugging!

  • 1

    Brigado Raphão Torres

Browser other questions tagged

You are not signed in. Login or sign up in order to post.