• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sorting/Pagination in large datasets

 
author
Posts: 469
20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

Is there any custom component which allows sorting/pagination efficiently when dealing with large data sets ?

The JSF data table or MyFaces datatable doesn't provide any such feature. I did found an article on MyFaces website which address the pagination issue in large data sets but it doesn't talk about how the sorting can also be achieved in case of large data sets: http://wiki.apache.org/myfaces/WorkingWithLargeTables

thanks
Ashish
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would prefer client-side sorting, using JavaScript. What say you?
 
Ashish Sarin
author
Posts: 469
20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Client side sorting won't be of much use because when doing sorting the expectation normally is that the whole dataset sorting is done. Will it be required to write a custom JSF component to handle this feature or MyFaces / JSF RI datatables can be extended to achieve this feature ?

-Ashish
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The whole data-set would be on display, I suppose. So, why not JavaScript sorting? Otherwise, we can write an order-by query.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it is not making any sound to you, you can look at RichFaces, ScrollableDataTable.
 
Ashish Sarin
author
Posts: 469
20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the JBoss RichFaces scrollable data table makes sense.
Still I would like to first know whether such a component is there or not or I need to write one for use in my JSF based application.

thanks
Ashish
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ashish Sarin:
Still I would like to first know whether such a component is there or not or I need to write one for use in my JSF based application.



Do you mean that, RichFaces, ScrollableDataTable is not there and you have to write it??
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Re: client-side sorting in JavaScript. The flaw with that concept here is that Ashish used the word "large". Now admittedly, my eyes begin to water when I'm about 8 pages into a multi-page data display, but sometimes you want to at least present the option (for example, Google search results).

But for the sake of bandwidth and response time, I'd rather not dump 30 million table rows on the client. And then sort them there. :shocked:

There's an extended version of the basic JSF datatable available from the Apache Myfaces Tomahawk project that can handle both pagination and sorting. The tag is self-contained - you don't have to write any JavaScript - and the heavy lifting is done all the way back at the database server, where various optimization tricks can ensure that the client and webapp don't have to do any more work than needed.

The 2 downsides are:

1. The pagination control has to follow the datatable (you can't display it up on top).

2. For best results you should set up a good set of CSS styles and button icons. It can work without them, but it's not very pretty.
 
Ashish Sarin
author
Posts: 469
20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. I completely agree with the approach you have mentioned. The tomhawk component can address most of the scenarios we come across in web applications but the extended data table available from tomahawk loads the complete dataset in one go. A way to ensure that not all data gets loaded in memory is to extend the JSF DataModel and modify some of its functionality ... for example, when asked for count it returns the dataset count (this will help the data scroller component to show all the page numbers and complete dataset count) and not just the count of records loaded in memory. So the pagination issue can be easily addressed by following this approach. What concerns me is how sorting can be addressed ? The sorting on a column should ideally result in query being re-fired to get the dataset sorted, not just the rows that were initialled loaded in the memory.

-Ashish
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tim Holloway:
[QB]Re: client-side sorting in JavaScript. The flaw with that concept here is that Ashish used the word "large". Now admittedly, my eyes begin to water when I'm about 8 pages into a multi-page data display, but sometimes you want to at least present the option (for example, Google search results).



He already mentioned that everything is fine with pagination, I believe. The only problem was sorting, as he mentioned. So, if its fine with pagination, that means we are having a handful of records on the client. JavaScript sorting makes perfect sense here, whether you write it yourself or use some library for that or use a ready-made component in which its in-build.

Thanks.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ashish Sarin:
What concerns me is how sorting can be addressed ? The sorting on a column should ideally result in query being re-fired to get the dataset sorted, not just the rows that were initialled loaded in the memory.



Get out of JSF and sort it on client-side, using JavaScript, and think as you are sorting in normal plain HTML.
 
Ashish Sarin
author
Posts: 469
20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Adeel. I will give it a try.
 
reply
    Bookmark Topic Watch Topic
  • New Topic