Reputation: 41
I am Using primefaces 6.0
with seam 2.2
and jsf 2.2
, trying to get the lazydatamodel
working on a p:dataTable
.
I have created my own LazyDataType specific to the entity in the datable and defined a load override method in the class.
The table is rendered correctly but i have to manually set first page of results when initialising it, the load method never gets fired on the table update.
I have noticed that when running through the Primefaces DataTable.class
in debug it encounters the - loadLazyData()
- method in this the correct model is found which is of my extended class of the lazyDataModel
type but when it gets to this line if(model != null && model instanceof LazyDataModel)
it returns false
.
The model object is definitely not null and my of the type of my class extending the LazyDataModel
type so this should return true
I am guessing this is why the load method doesn’t fire…
Has any one encountered this issue? Any help would be appreciated.
Thanks
My extended class is shown below
public class CompetitionUserLazyDataModel extends LazyDataModel<CompetitionUser>{
/**
*
*/
private static final long serialVersionUID = -5634037604279083091L;
private Competition competition;
public CompetitionUserLazyDataModel(){
}
public CompetitionUserLazyDataModel(Competition competition, int rowCount){
this.setCompetition(competition);
super.setRowCount(rowCount);
super.setRowIndex(0);
super.setPageSize(5);
}
@SuppressWarnings("unchecked")
@Override
public CompetitionUser getRowData(String rowKey) {
List<CompetitionUser> data = (List<CompetitionUser>) super.getWrappedData();
return data.get(Integer.parseInt(rowKey));
}
@SuppressWarnings("unchecked")
@Override
public Object getRowKey(CompetitionUser competitionUser) {
List<CompetitionUser> data = (List<CompetitionUser>) super.getWrappedData();
return data.indexOf(competitionUser);
}
@Override
public List<CompetitionUser> load(int first, int pageSize, String sortField,
SortOrder sortOrder, Map<String, Object> filters) {
CompetitionUserDAO competitionUserDAO = (CompetitionUserDAO)Component.getInstance("competitionUserDAO");
List<CompetitionUser> results = competitionUserDAO.getLazyListOfCompetionUsersForCompetetion(this.competition, first, pageSize);
this.setWrappedData(results);
this.setRowCount(this.competition.getNoCompetitors());
return results;
}
public Competition getCompetition() {
return competition;
}
public void setCompetition(Competition competition) {
this.competition = competition;
}
}
Upvotes: 0
Views: 783