title: Primefaces 5 Delete button inside a datagrid with confirmation box Pass parameter value to the bean on click of yes of confirmation box
body: <p>We are using Primefaces 5</p>
  
  <p>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</p>
  
  <p>Xhtml:-</p>
  
  <p></p>
  
  <p></p>
  
  <p></p>
  
  <pre><code>                    &lt;p:commandButton action="#{bean.deleteUser}" value="Delete"
  
                                              ajax="false" onclick="PF('confirmation').show()" type="button"&gt;
  
                      &lt;/p:commandButton&gt;
  
  
  
                      &lt;p:confirmDialog
  
                                  message="Are you sure about deleting the user?"
  
                                  header="Initiating user deletion" severity="alert"
  
                                  widgetVar="confirmation" appendTo=""&gt;
  
                                  &lt;p:commandButton value="Yes Sure" ajax="false" onclick="resetSearchForm()"
  
                                              oncomplete="PF('confirmation').hide()" action="#{bean.deleteUser}" &gt;
  
                                              &lt;f:param name="testUserId" value="#{user.id}"&gt;&lt;/f:param&gt;                                               
  
                                  &lt;/p:commandButton&gt;
  
                                  &lt;p:commandButton value="Not Yet" onclick="PF('confirmation').hide()"
  
                                              type="button" /&gt;
  
                      &lt;/p:confirmDialog&gt;
  </code></pre>
  
  <p></p>
  
  <p></p>
  
  <p>Bean:-</p>
  
  <pre><code>        public void deleteUser() {
  
                      String id = FacesContext.getCurrentInstance().getExternalContext()
  
                                                          .getRequestParameterMap().get("testUserId ");
  
          }           
  </code></pre>