• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sorting a map using struts tags.

 
Chris Kul
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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 !
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • 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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That kind of functionality *should* be handled on the Java side, in my opinion, for a variety of reasons.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic