I have created a component that has a delete button per row. When the delete button is clicked, a confirmDialog will be called and upon clicking 'Yes' on the dialog, the row will be deleted.
The table refreshes, but the wrong row is removed on the UI . On the bean, the correct record is deleted. On the UI side, the row removed is always the last row, no matter which row you pick to delete.
The Delete button is in the datatable itself and the confirmDialog is located outside the datatable but within the same form.
Does anybody know what is wrong?
<p:commandButton icon="ui-icon ui-icon-trash"
update="@form"
oncomplete="del_confirmation.show()"
value="Delete"
immediate="true">
<f:setPropertyActionListener value="#{item}"
target="#{Bean.recToDelete}"/>
</p:commandButton>
<p:confirmDialog widgetVar="del_confirmation"
message="Confirm Delete?"
header="Delete Dialog" showEffect="explode"
hideEffect="explode" modal="true">
<div align="center">
<p:commandButton id="delBtn"
icon="ui-icon ui-icon-check"
value="Yes"
actionListener="#{Bean.deleteRecord()}"
update="@form"
oncomplete="del_confirmation.hide()"
immediate="true"
ajax="true" />
<p:commandButton
icon="ui-icon ui-icon-cancel"
value="No"
onclick="del_confirmation.hide()" />
</div></p:confirmDialog>
p:datatable
... there is no caching in the table, also try removing the immediate and replace thef:setPropertyActionListener
by usingaction="#{myBean.myDeleteMethod(item)}"
– Daniel