Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RowSelect event p:dataTable

Tags:

jsf

primefaces

Need to capture the rowSelect event of a dataTable having checkbox based row selection. The code is as follows:

<p:ajax event="rowSelect" listener="#{articleBean.onRowSelect}"
                    oncomplete="articleBean.onSelection" />
<p:ajax event="rowUnselect" listener="#{articleBean.onRowUnselect}"
                    oncomplete="articleBean.onSelection" />
<p:column id="name" headerText="Select" selectionMode="multiple"
                    style="width:18px" />

I'm unable to understand the behavior. When I click checkbox for the first time, the method "onRowSelect" is getting called. When I unselect, "onRowUnselect" is not getting called. And also, the "onRowSelect" method is called just once for the grid, as in, if I click any other checkbox, the event is not getting triggered. Am I missing out anything? Not able to understand this behavior.

like image 639
Shikha Dhawan Avatar asked Feb 21 '12 05:02

Shikha Dhawan


1 Answers

As you are using dataTable with checkbox based row selection then you should replace:

<p:ajax event="rowSelect"
<p:ajax event="rowUnselect"

With the following:

<p:ajax event="rowSelectCheckbox"
<p:ajax event="rowUnselectCheckbox"
like image 54
dulon Avatar answered Nov 15 '22 11:11

dulon