• Post Reply Bookmark Topic Watch Topic
  • New Topic

help required on sorting data in a table + trinidad

 
Kumar Gaurav
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!