DataTable和LazyDataModel没有调用load

时间:2016-08-22 10:48:26

标签: jsf primefaces datatable seam lazydatamodel

我正在primefaces 6.0使用seam 2.2jsf 2.2,尝试让lazydatamodel处理p:dataTable

我已经创建了自己的特定于datable中实体的LazyDataType,并在类中定义了一个加载覆盖方法。

表格是正确呈现的,但我必须在初始化时手动设置第一页结果,加载方法永远不会在表格更新中被触发。

我注意到在调试中运行Primefaces DataTable.class时遇到了 - loadLazyData() - 方法,找到了正确的模型,这是lazyDataModel的扩展类。键入但是当它到达此行时if(model != null && model instanceof LazyDataModel) 它返回false

模型对象绝对不是null,而且我的类的类型扩展了LazyDataModel类型,所以这应该返回true

我猜这就是为什么加载方法不会触发......

有没有人遇到过这个问题?任何帮助将不胜感激。

由于

我的扩展课程如下所示

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;
 }
}

0 个答案:

没有答案