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

查看:22
本文介绍了高效的 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 展示示例.

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

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

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