File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Best way to make sortable columns?" Watch "Best way to make sortable columns?" New topic
Author

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
Roshani


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...

jan

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

Joined: Mar 22, 2005
Posts: 41060
    
  43
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.


Ping & DNS - my free Android networking tools app
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: http://aspose.com/file-tools
 
subject: Best way to make sortable columns?
 
Similar Threads
How to sort all the columns in a datatable
Nested JTable Header required
Is Struts still the way to go?
JClass software
I passed SCJD :)