File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Sorting a map using struts tags. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Sorting a map using struts tags." Watch "Sorting a map using struts tags." New topic
Author

Sorting a map using struts tags.

Chris Kul
Greenhorn

Joined: Jul 21, 2008
Posts: 3
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

Joined: Oct 08, 2009
Posts: 276
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

Joined: Sep 29, 2008
Posts: 12617

That kind of functionality *should* be handled on the Java side, in my opinion, for a variety of reasons.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sorting a map using struts tags.
 
Similar Threads
Scriptless page.
Struts 1: How to access Struts form data in JavaScript
How To Create a Form That Contains Two Drop-Down Menus?
html:select problem
bean:write property