File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Best way to make sortable columns? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Best way to make sortable columns?" Watch "Best way to make sortable columns?" New topic

Best way to make sortable columns?

Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
What do you think the ebst way is to make sortable columns in struts? Right now I have a table that I am iteration to populate. I have the headings set as hyperlinks that call a sort function and then redisplay the page with the sorted collection.
RoshaniG Gopal
Ranch Hand

Joined: May 15, 2006
Posts: 180
Hi Chris,
I have used Javascript to implement it. I couldnt think of anything else. It is quite simple with it.


Regards,<br />Roshani
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
hey chris,

check this out, it provides all the functionality out of the box...


#2, javascript to sort a table? wow...
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
Using JavaScript works well, e.g. check out this example. It can be extended using styles to highlight the sorted column, and columns containing numbers, text and dates can be treated differently. You could even add little up/down arrow icons in the table header, in order to indicate which column is sorted, and in which direction.
Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
Jan, I looked into the displaytag you suggested and it looks to be exactly what I need. However, I'm having a problem. I get the following message where my list should be

Nothing found to display.

The code I am using is:

I am using Struts, Spring, and Hibernate. I cannot include any scriptlets in the JSP code. My form bean's name is projectListForm per the mapping. The list within the form bean's name is projects. The 2 elements I am trying to iterate within the list are projectId and projectName. I am accessing the page via the .do which hits the database and populates the list before calling the jsp.
alan wamser
Ranch Hand

Joined: Jan 30, 2006
Posts: 41
Are you writing the list back to the request, request.setAttribute("projects" projects);
alan wamser
Ranch Hand

Joined: Jan 30, 2006
Posts: 41
Or is the project list part of the form bean? Then...

<display:table name="reqeustScope.projectListForm.projects" ...>
I agree. Here's the link:
subject: Best way to make sortable columns?
It's not a secret anymore!