sorting using display tag and Comparable interface
807597Nov 9 2005 — edited Nov 9 2005I am trying to use display tag for sorting data in table.
Would like to have the sorted list before it gets displayed in table.
Also, Would like to sort the entire data in the list not just page. Using Paging in display tag which would sort only the data in that page.
When I see the docs which says
If you want to allow the user to sort the data as it is coming back, then you need to just do two things, make sure that the data returned from your property implements the Comparable interface (if it doesn't natively - use the decorator pattern as shown a couple of examples ago), and then set the attribute sortable="true" on the columns that you want to be able to sort by.
Note the sortable attribute was previously named sort. The sort attribute is still supported for compatibility with previous versions.
When the user clicks on the column title the rows will be sorted in ascending order and redisplayed on the page. If the user clicks on the column title again, the data will get sorted in descending order and redisplayed.
Only the rows being shown on the page are sorted and resorted, so if you use this attribute along with the pagesize attribute, it will not resort the entire list. It is assumed that if you want to allow the user to resort a large list that will not all fit on a single page, then you will provide an interface which is more appropriate to that task.
*******************************************************
how do I have to use this Comparable interface?
Also, What kind of interface do I have to use to sort the whole list?
Thanks.