April 30th, 2011, 10:04 PM
sorting selected checkbox rows to the top of table
I am working on a project where we using technologies like Java, velocity etc. I am working on a task where I display data by means of a HTML table having 5 columns with 1st column being checkbox selection. I need some help with this - "If the user is going to select checkboxes on 1,3,5 rows then I need to move those selected rows on the top of this table." I am getting a Java Object and looping thru that Java Object in the velocity file using For Loop to display the data in this HTML table. someone advised me using Java comparator I can do this but I dont have much idea about it. Can someone please provide me code for how to do this. I very much appreciate your help.
May 2nd, 2011, 07:51 AM
Re: sorting selected checkbox rows to the top of table
Comparator is really very simple. It takes two Objects, in your case the checkBoxes, and returns an integer (1, 0, -1). Clearly the result says which one is "greater" or if the two are of equal value. This implementation you will then use with Collections.sort(someList, someComparator ).. and presto.
What do you not understand of this? We do not know your other existing business logic behind it, so asking someone else to write your code is usually likely to be less than helpfull. Google is your friend, and if that does not help specific questions with code samples describing your issue and implementation is the best way here.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.