I'm trying to update a dataTable after deleting an element from the dataTable, but it is not working properly. I have to refresh the page in order to have the dataTable updated or after many clicks on delete button, the table is rendered again without having to manually refresh the whole page.
Example of record to be deleted!
If I click on delete, it is indeed deleted, however, dataTable is not re-render until I refresh the page.
Recorded deleted after I refresh the whole page or click delete button many times
According to the primefaces documentation tag update should update partially the page.
https://www.primefaces.org/docs/vdl/3.5/primefaces-p/menuitem.html
[![enter image description here][3]][3]
This is my code, everything seems to be correct but, probably I'm missing something.
<h:form id="form">
<p:dataTable id="studentsDataTable"
value="#{studentsController.students}"
var="student"
rowKey="#{student.username}"
selection="#{studentsController.studentSelected}"
selectionMode="single">
<!--Header-->
<f:facet name="header">
Spanish Academy : Students' List
<p:button value="Add Student" outcome="new_student" />
</f:facet>
<p:column headerText="Username">
<h:outputText value="#{student.username}" />
</p:column>
<p:column headerText="Firstname">
<h:outputText value="#{student.firstname}" />
</p:column>
<p:column headerText="Lastname">
<h:outputText value="#{student.lastname}" />
</p:column>
<p:column headerText="Edit" style="width:50px">
</p:column>
<!--Footer-->
<f:facet name="footer">
<p:commandButton value="Delete" process="@form" update="form:studentsDataTable" actionListener="#{studentsController.deleteStudent}" icon="ui-icon-close"/>
<p:spacer height="5px;"/>
</f:facet>
</p:dataTable>
</h:form>
Any idea guys?
Thanks in advance.