I have the following to display data.
<p:dataGrid
id="employeeList"
var="employee"
rowIndexVar="rowIndex"
value="#{sampleController.employeeRecords}"
columns="1"
layout="grid"
rows="10"
paginator="true"
emptyMessage="No items to display..." > ..... </p:dataGrid>
and my controller(sampleController)
has the following getter setter
private List<EmployeeVo> employeeRecords;
public List<EmployeeVo> getEmployeeRecords()
{
return employeeRecords;
}
public List<EmployeeVo> setEmployeeRecords()
{
return employeeRecords;
}
and have one more method which sets the value to employeeRecords
like the following
public void loadEmployee(){
List<EmployeeVo> list = //call to DB
setEmployeeRecords(list);
}
and everything works fine except the pagination. Whenever I click on the page numbers
, the control goes to getter method (setEmployeeRecords()) more than once and the values in the list gets manipulated and final results are not proper.
Why does clicking on page number takes me to getter method and is it not managed in the client level?
Note I have not done anything the getter or setter. They are plain getter and setter. setting the values is done only once in the following:
public void loadEmployee(){
List<EmployeeVo> list = //call to DB
setEmployeeRecords(list);
}
and the call never goes there too whenever I click on the page numbers.