I have a situation where the pagination should be dynamically. Meaning that it should change with each call of the load method.
I want set the setRowCount() method dynamically and give the pagination for the dataTable
@Override
public List<ProjectMasterModel> load(int first,int pageSize,StringsortField, SortOrder sortOrder, Map<String, String> filters) {
List<ProjectMasterModel> data=new ArrayList<ProjectMasterModel>();
LazyDataModel<ProjectMasterModel> newdata = null;
ProjectMilestoneDaoImpl milestoneDaoImpl=(ProjectMilestoneDaoImpl) ObjectFactory.getBean("projectMilestoneDao");
SessionFactory sessionFactory=(SessionFactory) ObjectFactory.getBean("sessionFactory");
sessionFactory.getCurrentSession().beginTransaction();
try{
data.addAll(milestoneDaoImpl.populateLazyRandomProjects(first,pageSize));
setRowCount(milestoneDaoImpl.getRowCount_Of_ProjectList());
// very important line to show the pagination
}catch(Exception e){
CmsLogger.errorLog(LazyProjectDataModel.class, e);
}finally{
sessionFactory.getCurrentSession().close();
}
if(sortField != null)
Collections.sort(data,new ProjectMasterModel());
return data;
}
Here I have used a query to fetch the data size to set the row count. In a given situation their may be number of records added to the Database. So The pagination should increment dynamically. But if I change the setRowCount() method to a dynamic value it doesn't reflect it keeps its original value which was set for the first time.