• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Scrolling + sorting a datatable

 
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I need help in order to implement a scrolling combined with a sorting strategy for a datatable.

Here is the behaviour I need:

A user should be able to scroll a datatable in steps of N records. He/she should then be able to sort that N records and not the whole of the resultset.

My problem is that I copied and pasted code in order to implement the sorting strategy and then copied and pasted code in order to implement the scrolling strategy and now I have the following behavior: the user can scroll but when he/she attempts to sort, the whole of the resultset is sorted and records not belonging to the "page" (of N records) are displayed.

Here is the Datamodel:



The code for the managed bean is as follows:



Here are the relevant snippets from my JSPs:



I am at a loss on how to proceed in order to make it work.

Can anyone help please?

Thanks in advance,

Julien.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSF can do the data scroller by using the dataScroller, and the use this comparator for sorting and pass back the list to dataScroller.

Comparator comparator = new Comparator()
{
public int compare(Object o1, Object o2)
{
Account e1 = (Account)o1;
Account e2 = (Account)o2;
if (column == null )
{
return 0;
}else
if (column.equals("AccountID"))
{
if (e1.getIdAcct() == null){
return 1;
} else if (e2.getIdAcct() == null){
return 0;
}
return isAscending() ? e1.getIdAcct().compareTo(e2.getIdAcct()):e2.getIdAcct().compareTo(e1.getIdAcct());
}
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can also try out the a4j datascroller..
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic