JBoss Seam - 处理从 SQL 返回的大数据
我正在寻找技术/最佳实践来处理我们基于网络的应用程序的工作方式。
目前,当用户搜索某个字段时,它可以一次返回超过 10000 条记录,这对我来说是浪费带宽和内存。
有没有办法根据选择显示的行数来限制返回的行数。即,如果在网页上用户选择每页 100 行,则仅返回 100 行,而不是一次加载所有 10000 行,那么当单击下一页时,将加载接下来的 100 行,依此类推。
更新:当前实现获取所有数据,将其绑定到 t:datatable
和 t:dataScroller
以在页面之间导航。
根据我在 JFS 1.1 中的阅读,没有提供服务器端分页(如果我错了,请纠正我),为了提供这种机制,我需要编写自定义代码,例如 http://wiki.apache.org/myfaces/WorkingWithLargeTables
有人可以确认这是一个好的解决方案吗?使用 RichFaces 不是一种选择。
谢谢
I'm looking for techniques/best-practices to do deal with the way our web-based application works.
Currently when a user searches a field it can returns more than 10000 records at once which to me is a waste of bandwidth and memory.
Is there a way to limit the number of returned rows based on the numbers of rows selected to display. i.e. if on the web page user selects 100 rows per page then only return the 100 rows instead of loading all 10000 at once , then when next-page is clicked the next 100 number of rows will be loaded and so on.
UPDATE : The current implementation fetches all the data, binds it to the t:datatable
and t:dataScroller
for navigation between the pages.
From my reading in JFS 1.1 there is no server-side pagination provided (Correct me if i'm wrong) and to provide such mechanism i need to write custom code such as http://wiki.apache.org/myfaces/WorkingWithLargeTables
Can someone confirm is this is a good solution? Using RichFaces is not an option.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该使用 jsf 组件进行服务器端分页,例如 richfaces 中的示例:
http://katzmaier.blogspot.com/2010/03/richfaces-server-side-pagination.html
You should do server-side pagination using a jsf component, as an example in richfaces:
http://katzmaier.blogspot.com/2010/03/richfaces-server-side-pagination.html
能否使用Paginator组件来控制相关条数记录的显示?
如果您需要限制返回的行数,可以将其指定为查询语法的一部分。
Could you use a Paginator component to control the display of the relevant number of records?
If you need to restrict the number of rows returned this can be specified as part of your query syntax.
看一下entityquery 类。这个已经支持服务器端分页和排序。它适用于简单或丰富的数据表。如果您需要一些轻量级的东西,甚至在普通 jsf 之上的 jquery 数据表也是可能的。
Take a look at the entityquery class. This one supports already server-side pagination and sorting. It works well with simple or richfaces datatables. Even jquery datatables on top of the plain jsf one is possible if you need some lightweight stuff.