We are using Primefaces 5
We are having one datagrid for search results. Inside datagrid there is one delete button for every row. Onclick of delete button a confirmation box is being displayed when the user clicks on yes button of confirmation dialog box then deleteUser method of bean should be called and the user with value of parameter id ‘testUserId’ should be deleted. Problem is the value of ‘testUserId’ which is being sent to bean is always value of userId of the last row of the datagrid. How to pass the value of the 'testUserId' of the current row from where delete button is clicked to the bean method? Given below is the snippet of the code
Xhtml:-
<p:commandButton action="#{bean.deleteUser}" value="Delete"
ajax="false" onclick="PF('confirmation').show()" type="button">
</p:commandButton>
<p:confirmDialog
message="Are you sure about deleting the user?"
header="Initiating user deletion" severity="alert"
widgetVar="confirmation" appendTo="">
<p:commandButton value="Yes Sure" ajax="false" onclick="resetSearchForm()"
oncomplete="PF('confirmation').hide()" action="#{bean.deleteUser}" >
<f:param name="testUserId" value="#{user.id}"></f:param>
</p:commandButton>
<p:commandButton value="Not Yet" onclick="PF('confirmation').hide()"
type="button" />
</p:confirmDialog>
Bean:-
public void deleteUser() {
String id = FacesContext.getCurrentInstance().getExternalContext()
.getRequestParameterMap().get("testUserId ");
}