This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

sorting problems in struts jsp

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a page that displays a table with strings coming from collections in multiple columns. When i click on the header, i want the table to be sorted by that column. Can anyone please give me a sample code for the same. This is urgent.

The data table is like: table name is in postgresql : mydata

Company Name Name Email Id Address
--------------------------------------------------------------
TEST COMP Ravi ravi@ravi.com loc1,
COMP ABC Kiran kiran@bl.com loc2,

When i click on the Company Name, i want the table to be sorted by the Company name column.

using with struts jsp .
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's one way of doing it:

Create an action that basically loads your resultset, and forwards to the display page. Make the column headings links that link to that action, with parameters in the href attribute like:

href="myaction.do?orderby=firstColumnName"
href="myaction.do?orderby=secondColumnName"
href="myaction.do?orderby=thirdColumnName"

Now in your action class, where you load the resultset by running a query, you just include whatever orderby clause in the actual query.

e.g. "SELECT * FROM tblTest ORDER BY " + request.getParameter("orderby")
This is of course not recommended unless you use prepared statements AND check the values of the "orderby" parameter for validity.

I have not found any other way of sorting a resultset, so if anyone out there knows of a better way - plz share!

[ November 07, 2005: Message edited by: Scheepers de Bruin ]
[ November 10, 2005: Message edited by: Scheepers de Bruin ]
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi smitha

You have many third party components which does the things for you . ofcourse you can implement on your own those things which is not really an ardous task . But the third party tools already in place will give you many options for navigating to different set of records and all
 
I have always wanted to have a neighbor just like you - Fred Rogers. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic