开发者

JSF 2 with PrimeFaces: dataTable page numeration not working

I'm using Mojarra 2.0.3 on Tomcat 6.0 and PrimeFaces 2.

I use a dataTable with lazy-loading, which works without problems. Now 开发者_Python百科i added pagination and the table calculates the number of pages not correctly.

<p:dataTable id="tableList" value="#{overview.lazyModel}" rendered="#{!overview.listEmpty}" var="e"
    paginator="true" rows="10" lazy="true"
    paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
    rowsPerPageTemplate="5, 10, 20, 50">

On first load, sometimes it displays no data, though the bean sent it correctly (I print the data, sent to the table, into the Tomcat-console) and also the data from the table (pagesize, filters, sortMode, ...) is correct.

lazyModel = new LazyDataModel<Bericht>() {
    @Override  
    public List<Bericht> load(int first, int pageSize, String sortField, boolean sortOrder, Map<String,String> filters) {
        List<Bericht> lazyBerichte;     

        lazyBerichte = [...]; // fill data
        setRowCount([...]); // set row count

        return lazyBerichte;
    };          
}

I hope that it's not a bug in primefaces, because i can't wait until the new version is out (project must be ready in 5 weeks).

Does anyone have an idea? I tried everything out but nothing is working.

Greets from germany, Andy


I faced this problem today, and found a workaround to this problem. Simply add this line after your lazyModel instantiation:

lazyModel.setRowCount(1);

Lazy data table not showing the contents of the initial page

It worked fine to me.


I faced same problem. I resolved it (on PF2.2RC) using lazyModel.loadLazyData().

Lazy Loading + Command Button on Primefaces

Try use it on your instantiation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜