Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best way to make sortable columns?

 
Chris Boldon
Ranch Hand
Posts: 190
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chris,
I have used Javascript to implement it. I couldnt think of anything else. It is quite simple with it.

Regards
Roshani
 
Jan Groth
Ranch Hand
Posts: 456
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey chris,

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

jan

#2, javascript to sort a table? wow...
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 190
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you writing the list back to the request, request.setAttribute("projects" projects);
 
alan wamser
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic