aspose file tools*
The moose likes JSP and the fly likes Help with sorting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Help with sorting" Watch "Help with sorting" New topic
Author

Help with sorting

jay lai
Ranch Hand

Joined: Apr 04, 2002
Posts: 180
I am using JSTL and Hibernate to get data. Now i need to sort the columns that display on the jsp such as click of "ID" columsn , it will sort by asc or desc, so on and so forth.
please help me with any hints or clues.
Many thanks in advance

Sample of the the jsp display



[ March 01, 2007: Message edited by: Bear Bibeault ]
[ March 01, 2007: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

"Pls" is not a word. Please use real words such as "Please" when posting to the forums. Please read this for more information.

Also, as this has nothing to do with apllication frameworks, it has been moved to the JSP forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

As with all other large problems, start one step at a time.

I assume that you want to sort upon a click of the column header, right?

Start there. How would you display an alert when the user clicks on the header?
jay lai
Ranch Hand

Joined: Apr 04, 2002
Posts: 180
There won't be any alert, just like normal sorting , display as **a link** <a href> to the header, and if you click the links it will sort the column
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

No, my point with the alert is that it's the first step to checking that your code reacts to the mouse click. It would be replaced with real code once you get to that point.

Again, one step at a time. Let me know when you've got the column header rigged up to react to a mouse click.
Naveen Kumar
Ranch Hand

Joined: Dec 14, 2006
Posts: 35
Hi Jai,

Below Link Will Help To you.

http://www.mingyi.org/other/ts_demo.html

Regards
Kumar
jay lai
Ranch Hand

Joined: Apr 04, 2002
Posts: 180
Hi Kumar:
Thanks, I am going to take a look and let see if I can use for my stuff.
Regards
Karthik Srikanti
Greenhorn

Joined: Sep 20, 2006
Posts: 11
Jay,

You can use the link given by Kumar if your data has no pagination. But if you need pagination, or if you dont want to use javascript, you can use display tags. You can seamlessly fit into your application and pass it an object in any scope in the page. You can configure sorting. You can get them at this link

http://displaytag.sourceforge.net/11/

Cheers


{ SCJP, SCWCD, SCBCD, OCA (DBA) }
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Instead of doing this in Java, you could also handle this in JavaScript on the client (if you can require JS). Have a look at the table at the bottom of this page. This technique also knows how to sort text, numbers and dates differently. It slows down for really large tables, though. Feel free to steal the JS


Ping & DNS - updated with new look and Ping home screen widget
jay lai
Ranch Hand

Joined: Apr 04, 2002
Posts: 180
Hi,
thanks for the hints, I tried to plug in the javascript that Kumar has refered to , it works fine, the only problem i have is, I added a column with checkbox into the table, so if the user **select check box ** and then do ** sort **, if I right click and view source from the browser, the order of the record is not match with the checkbox.
Meaning, the sorting on client site only, so the order of records first time load the page, stay the same, so you could select checkbox with value=25, but behind the scence it is still checkbox with value=1.
Sample:


So any better way to resolved this problem, Again thanks in advance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with sorting
 
Similar Threads
serve html
display array from servlet
Dynamic population of second list box based on selection of first
Default JSTL URI can't be resolved
c:url parsing problems