Ok, this is embarrassing, of course HashMap doesnt guarantee the order, TreeMap did the trick, sorry :)
Oleg On 10/14/05, Oleg <[EMAIL PROTECTED]> wrote: > I have been hours at this, going crazy. I am setting up Dynamicly sized form. > > struts-config.xml > ----------------------------------------- > <form-bean name="dynamicHashmapForm" > type="org.apache.struts.validator.DynaValidatorForm"> > <form-property name="fields" type="java.util.HashMap" /> > </form-bean> > > My Action, gets the map like so: > > DynaValidatorForm df = (DynaValidatorForm) form; > HashMap hm = (HashMap)df.get("fields"); > > Than I try to populate it from database like so: > > int count = 0; > while more in array { > Field f = new Field(); > f.setName("some name from database"); > hm.put(count,f); > count++; > } > > I did a break point within a loop and while records and after two > records added to the HashMap, I see a HashMap of size 16 with array[0] > record placed at map[6] and array[1] record placed at [1]. > > So when I display records with c:forEach loop: > <c:forEach var="field" items="${dynamicHashmapForm.map.fields}"> > <c:out value="${field.value.name}"/> > </c:forEach> > > It all our of order! Any ideas guys as to how to keep it ordered? > > Thanks > Oleg > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]