• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Best way to make sortable columns?

 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or is the project list part of the form bean? Then...


<display:table name="reqeustScope.projectListForm.projects" ...>
 
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic