Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

To do ajax refresh of JSF/primefaces datatable  RSS feed

 
Raghu Sundar
Ranch Hand
Posts: 40
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to do JSF/primefaces ajax update on the datatable on click of a command link using which i am deleting the records.On clicking the command link i the database get supdated but the datatable doesn't get refreshed even if i use update="@form" attribute.Any guidance on how to solve this problem would be very helpful.

My JSF code snippet


The variable lpcIdData is of the type of the class that implements DataModel.

Below is the Managed bean snippet that contains deleteRecords method.Managed bean is of RequestScoped



The variable selectedRows is the selection attribute of the datatable



 
K. Tsang
Bartender
Posts: 3639
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are updating the "@form"? Is there an element with id="@form"? I doubt.

In the p:commandLink you should use update="lpcDataTable"

Also in your deleteRecords() method, is it necessary to create a new connection every time? Why can't the connection be outside the for loop? And you should close such connection when done.
 
Raghu Sundar
Ranch Hand
Posts: 40
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Tsang for your reply,but the result is the same, the datatable is not getting refreshed :( , but i need to manually refresh the web page.
 
K. Tsang
Bartender
Posts: 3639
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the code get inside the for loop?

Is the method getting the "correct" record for delete? Because I don't see any get values from request map stuff.

Further check, your for loop seems to be deleting each record one by one!!

Since you are using a link, try passing in the id of that row or some key instead of looping the entire collection/list or whatever.

If everything is working in the delete method, try reloading the data model.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!