HashMaps will rearrange stuff internally and will NOT preserve the original
order (see the j2se javadocs for details).

There is a class in commons-collections (which should already be on your
classpath as struts (1.1 anyway) uses this library) called
SequencedHashMap - try using this instead as it preserves the order in which
stuff was added to the hashmap and uses this order in its iterator.

(This was introduced in commons-collections 2.0 so if your using an older
version you may need to upgrade the jar with the latest.

Heres the javadoc for it:
http://jakarta.apache.org/commons/collections/api/org/apache/commons/collect
ions/SequencedHashMap.html

-----Original Message-----
From: O_Parthasarathy Kesavaraj [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 8 July 2003 13:17
To: 'Struts Users Mailing List'
Subject: Urgent!!!Sorting Problem while loading from HashMap


Hi
I am loading a html:select box with property as the key in the HashMap( ID
corresponding to the value which is displayed) and labelproperty as the
value.When i am fetching from the database i am sorting by the value and
then only loading in the HashMap.But when i see the select box the values
are not sorted..which makes my form not so userfriendly...Kindly help to
display sorted when i am loading from a HashMap...(When i load using an
araylist it displays the values in the order i have stored and there is no
sorting problem)

Thanks in Advance
Regds
Partha

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to