This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Best way to make sortable columns?

 
Ranch Hand
Posts: 190
  • 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.
 
Ranch Hand
Posts: 180
  • 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
 
Ranch Hand
Posts: 456
  • 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...
 
Rancher
Posts: 43011
76
  • 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
  • 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.
 
Ranch Hand
Posts: 41
  • 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
  • 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" ...>
 
BWA HA HA HA HA HA HA! Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!