PrimeFaces lazydatamodel加载方法未调用 [英] PrimeFaces lazydatamodel load method not called
本文介绍了PrimeFaces lazydatamodel加载方法未调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我碰巧不明白为什么我的primefaces表的lazydatamodel中没有调用我的load方法.我的xhtml页面是这样的
I happen not to understand why my load method is not called in a lazydatamodel of my primefaces table. My xhtml page goes like this
<h:form id="myForm">
<p:dataTable value="#{myBean.configDataModel}"
id="configTable" var="config" paginator="true" rows="10"
selectionMode="single"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,20">
.
.
</h:form>
我的Bean代码是这样的,并放置了system.out.println语句,但我注意到它没有被调用.
My Bean code goes like this and put up system.out.println statements but I notice it isn't called.
public class MyBean{
// private List<MyBean> configList;
private LazyDataModel<MyBean> configDataModel;
@SuppressWarnings("serial")
public LazyDataModel<MyBean> getConfigDataModel() {
if (configDataModel == null) {
configDataModel = new LazyDataModel<MyBean>() {
@Override
public List<MyBean> load(int arg0, int arg1, String arg2,
SortOrder arg3, Map<String, String> arg4) {
System.out.println("Here!!!!!");
return null;
}
};
}
return configDataModel;
}
public void setConfigDataModel(LazyDataModel<MyBean> configDataModel) {
this.configDataModel = configDataModel;
}
}
可能是什么原因?
推荐答案
自PrimeFaces 3.3起,您需要将重复组件的lazy
属性显式设置为true
,以启用对
Since PrimeFaces 3.3, you'd need to explicitly set the lazy
attribute of the repeating component to true
in order to enable the support for LazyDataModel
.
<p:dataTable ... lazy="true">
另请参见:
- PrimeFaces展示柜-数据表-延迟加载
- PrimeFaces showcase - DataTable - Lazy Loading
See also:
这篇关于PrimeFaces lazydatamodel加载方法未调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文