Originally posted by A Patel: I have a HashMap in my action class that looks somewhat like this:
[key1=value1, key2=value2, keyn=valuen, ""=null]
I make this HashMap available in the session and use it to populate my drop down combo box in my JSP. So the drop-down list looks like so:
key1 key2 keyn <blank string>
I want to push the <blank string> to the top as the default value for my drop-down list so that my list looks like so;
<blank string> key1 key2 keyn
How can I achieve this? I'd appreciate any assistance in getting me started to do this.
Isn't that the risk you take when using HashMap? if I remember correctly with hashmap you can forget sorting (or first go in, first come out). Maybe an idea to put the ""=null option manually in the dropdown and populate the rest with the hashmap? Or use a List populated with object (TO or pojo) that has to attributes: the key and the value.