I am using primefaces and JSF 2.0. I have a data table with a delete column that looks like this.
<p:column id="Delete" headerText="Delete">
<p:commandButton icon="delete" onclick="deleteConfirmation.show()" style="align:center">
<f:setPropertyActionListener value="#{item}" target="#{controller.selectedItem}" /> </p:commandButton>
</p:column>
//Delete confirm dialog
<p:confirmDialog id="deleteConfirmDialog" message="Are you sure you want to delete?"
header="Delete" severity="alert"
widgetVar="deleteConfirmation">
<p:commandButton id="confirm" value="Yes"
update=":myList" oncomplete="deleteConfirmation.hide()"
actionListener="#{controller.delete}" />
<p:commandButton id="cancel" value="No"
onclick="deleteConfirmation.hide()" type="button" />
</p:confirmDialog>
Everything works great, except when i do filtering on the data table. After i filter and click delete, the selectedItem method gets the previous row in the data table( which is not part of filter result) instead of the current row.
This problem does not exist without filtering.
I am using ViewScoped scope for my controller.
Any ideas on why this is happening? This seems like a basic thing that should be supported by a data table, so i am assuming that i am doing something wrong here. Thanks for your help
Its cause you are using pf version prior to 3.4 or you are not using the newly introduced in 3.3
filteredValueattributeThis new feature was introduced cause of the following opened issue DataTable filtering problem and ActionSource Components
Take a look at the showcase (that is using 3.4)
DataTable – Filtering
Edit
After reading your comment
I got the following to say :
Yup , its cause you probably not removing it from the list that is being referenced by the filteredValue attribute… (remove the row from that other list in case that the other list is not null) , weird solution? I think so too… Although I can understand the logic behind the idea of executing the filtered list after we are in filter mode… but still…
take a look at the following forum thread I posted several days ago
3.4 datatables execute of table affects filteredValue only?
feel free to post a rely there too 🙂