我有一个基于 JBoss Seam、RichFaces 和 Hibernate/JPA 的应用程序。我创建了一个 DAO 类和几个业务层类,用于根据各种条件检索数据。 (获取最新的、浏览全部等)我想返回这些结果并向用户显示它们,允许用户对它们进行分页。但是,由于返回的对象可能相当大(并且有大量对象),我不想使用类似
和 < rich:datascroller/>
这需要我在一个大型查询中检索所有对象并将它们维护在内存中。
是否有任何普遍接受的模式来执行数据集的服务器端分页?我正在寻找一种策略:
- 使用起始索引和计数检索数据的子集
- 使用“下一个”和“上一个”按钮滚动数据集,从而使用更新的起始索引和计数检索数据的新子集
你们中是否有人见过自定义 DataModel 对象,这些对象允许我使用
和
但仍执行服务器操作使用子集查询进行侧分页?我非常想了解您处理这种情况的方法。
I have an application based on JBoss Seam, RichFaces, and Hibernate/JPA. I've created a DAO class and a couple of business-layer classes that are used to retrieve data based on various criteria. (Fetch most recent, browse all, etc.) I'd like to return these results and display them for the user, allowing the user to paginate through them. However, since the objects returned can be rather large (and there is a large number of objects) I'd prefer not to use something like <rich:dataList />
and <rich:datascroller />
which would require me to retrieve all the objects in one large query and maintain them in memory.
Are there any generally-accepted patterns for performing server-side pagination of datasets? I'm looking for a strategy for:
- Retrieving a subset of my data using a start index and count
- Scroll through the dataset using 'next' and 'previous' buttons, thereby retrieving a new subset of the data using an updated start index and count
Have any of you seen custom DataModel objects that would allow me to use <rich:dataList />
and <rich:datascroller />
but still perform server-side pagination using subset queries? I'd be very curious to learn of your methodologies for handling such a scenario.
发布评论
评论(1)
Seam 应用程序框架中有一个内置的服务器端分页。只需看看 EntityQuery 对象。
您可以轻松地扩展这些类,并且在使用 getResultList() 时基本上可以免费获得分页。
但是,在开始到处扩展这些类之前,请先查看一下 此博文。
There is an in-built server side pagination in Seam Application Framework. Just have a look at the EntityQuery objects.
You can easily extends those classes, and basically get pagination for free when using
getResultList()
However, before you start extending those classes everywhere, take a look at this blog post.