• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

options sorting on property?

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to sort the list in the following select on the budgetName property, can I do that within struts?
If not and I sort the list of javabeans in the collection before going onto the page, is it guaranteed that the beans would be accessed in order?

Any suggestions would be appreciated
thanks
B
[smilies disabled by moderator]
[ October 24, 2003: Message edited by: Junilu Lacar ]
 
Marshal
Posts: 15630
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use a List (e.g. ArrayList) and the order will be retained.
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We build most of our collections stuff in TreeList and everything comes out in order. I've never had any issues.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If budgetlist is a List, call the Collections.sort() method.
You have two choices:
1) Implement the Comparable interface for the class of objects stored in your collection (Budget class?)
or
2) Use the overloaded sort() method which accepts a Comparator
For approach 1), add this line to your code which retrieves the budgetlist:
Collections.sort(budgetlist);
-Mark
 
Busty Sinclair
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought there might be some struts way I could include which property to sort on. Mark, your 2nd approach seems to be what I need, I'll write a comparator class. Thanks for the replies all. B
 
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic