aspose file tools
The moose likes JSF and the fly likes help required on sorting data in a table + trinidad Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "help required on sorting data in a table + trinidad" Watch "help required on sorting data in a table + trinidad" New topic
Author

help required on sorting data in a table + trinidad

Kumar Gaurav
Ranch Hand

Joined: Apr 08, 2008
Posts: 108
Hi All,

can any one provide me sample code on how to implement sorting in table on any column.
Can i do sorting in jsp page or do i need to write java code for the same.

Any help would be great


Regards,
Gaurav
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
JSP is just a presentation technology and should in fact not contain any business logic/algorithms.

You can do the sorting either at client side using Javascript code, or at server side using Java code. When you want to do it using Java code, then you can do the sorting either at Java level using Comparator/Comparable API's, or at database level using JDBC/SQL.

Doing so with Javascript is the fastest, but the data at the server side remains unsorted so you need to pass the sorting parameters to the server side as well whenever you want to retain the sorting on the next request. Doing so with Java code at Java level is inefficient and may be memory hogging when the data is large. Doing so with Java code at database level is far more efficient (if written properly).

That said, I don't know Trinidad, but have you checked if it doesn't provide a sortable table (or column) component? That would be much more easier. Just let Trinidad do all the sorting work. Consult the documentation along it for details. It is also available at their homepage as well.


Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: help required on sorting data in a table + trinidad
 
Similar Threads
JTable header click event ?
datatable with sorting in jsf
How to avoid server calls in Sorting
Welcome Chet Haase and Romain Guy
Table sorting queries