• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sorting a map using struts tags.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Experts !


I have a map(basically hashmap) on JSP available that needs to be used to render a part of the JSP page. As all of you know, a hashmap doesn't maintain order(Ascending/descending) of keys, I need to somehow sort the data. I don't want to do it through code (basically write function or java code, but use only struts tags)and if that is the only option I know how to do it. So my question is,

1. Is it possible to do this using struts tags(for example, logic:iterate) only?
2. I think I can use labelvaluebean. But still I need to put the data from hashmap into the labelvaluebean and then sort it. Correct me if I am wrong. If you can show me an example, that will be great !
3. Putting the hashmap data in another map which provided map data in sorted order.

Thank you very much !
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

C Kul wrote:
1. Is it possible to do this using struts tags(for example, logic:iterate) only?
2. I think I can use labelvaluebean. But still I need to put the data from hashmap into the labelvaluebean and then sort it. Correct me if I am wrong. If you can show me an example, that will be great !
3. Putting the hashmap data in another map which provided map data in sorted order.



1. No.
2. You'd still need to sort the List containing the LabelValueBeans...
3. Yes, you could use SortedMap, for instance.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That kind of functionality *should* be handled on the Java side, in my opinion, for a variety of reasons.
 
reply
    Bookmark Topic Watch Topic
  • New Topic