高效的JSF分页 [英] Efficient JSF Pagination

查看:89
本文介绍了高效的JSF分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JSF 2.0应用程序中最有效的分页方法是什么? 我使用Primefaces数据表,它足够智能,可以执行 分页本身,根本没有编码.

Whats the most efficient way of doing pagination in JSF 2.0 app? I use Primefaces datatable and it is intelligent enough to perform pagination by itself with no coding at all.

<p:dataTable var="car" value="#{carBean.cars}" paginator="true" rows="10">
    <!-- Multiple columns here-->
</p:dataTable>

我看到的是,我需要将bean放置到会话作用域或更大的会话范围内.

The thing that I see, is that I need to place my bean to session scoped or greater.

@ManagedBean
@SessionScoped
public class CarBean{
    public List<Car> getCars(){
        //return data from DB
    }
}

我想知道还有另一种有效的方法来执行此操作吗?

I wanted to know is there another efficient way on how to perform this?

顺便说一下,我在后端使用了EJB/JPA.想知道任何链接或教程 进一步了解这一点.

I used EJB/JPA at the backend by the way. Would like to know any links or tutorials to learn more about this.

谢谢.

推荐答案

您需要使用LazyDataModel来使客户端实际需要查看的内存行. 请参见PrimeFaces展示柜中的示例.这是您最终想要的在数据库级别的分页.

You need to use LazyDataModel in order to have only the rows in memory which the client actually needs to see. See also the example in PrimeFaces showcase. This does pagination at DB level which is what you ultimately want.

RichFaces以与ArrangableDataModel相同的方式支持

RichFaces supports by the way the same in flavor of ArrangableDataModel, here's the RichFaces showcase example.

这篇关于高效的JSF分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆