How to deselect the selected rows in Datatable programmatically

datatable, jsf-2, primefaces

Solution

You try:

<p:commandButton value="Reset" update="userListForAdminpopup" process="@this" actionListener="#{activityListController.hand}"/>

Bean:

public void hand(){
   selectedActivityUsers = new ActivityUsers(); // Type of element of list
}

Problem

In my application in a `dialog` I displayed a `dataTable` in each column there are a check box to select corresponding row. At the bottom of `dialog` I paced two button one for display selected rows another for reset the datatable means to deselect the selected rows. .xhtml code is given below: ``` <p:dialog id="popUp" header="Activity Detail" widgetVar="popUpWidget" showEffect="fade" hideEffect="explode" resizable="false" modal="true"> <h:panelGrid> <p:row> <p:column colspan="2"> <p:dataTable id="userListForAdminpopup" value="#{activityListController.activityUsers}" var="user" paginator="true" paginatorPosition="bottom" widgetVar="userListForAdminpopUp" paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}" rows="10" selection="#{activityListController.selectedActivityUsers}"> <p:column headerText="#{adbBundle['fullName']}" sortBy="#{user.lastName}" filterBy="#{user.fullName}" filterMatchMode="contains" styleClass="userName"> <h:outputLabel value="#{user.firstName}" /> </p:column> <p:column selectionMode="multiple" /> </p:dataTable> </p:column> </p:row> <p:row> <p:column colspan="2"> <h:panelGroup layout="block"> <p:commandButton value="Update" oncomplete="confirmation.show()"/> <p:commandButton value="Reset"/> </h:panelGroup> </p:column> </p:row> </h:panelGrid></p:dialog> ``` I want to deselect the rows when click on reset button. How it can be done?

Original source