spring - form:radiobuttons wrong list order -


brownser showing bad radio buttons order. dont know why changes showing order.

i want this

actually showing this(wrong)

code shown in brownser(wrong):

<input id="sdh.iesdfact1" name="sdh.iesdfact" type="radio" value="3"/> <label for="sdh.iesdfact1">con facturas</label>  <input id="sdh.iesdfact2" name="sdh.iesdfact" type="radio" value="2"/> <label for="sdh.iesdfact2">facturas requeridas</label>  <input id="sdh.iesdfact3" name="sdh.iesdfact" type="radio" value="1" checked="checked"/> <label for="sdh.iesdfact3">sin facturas</label> 

aplication code: jsp code:

<label for="sdh.iesdfact”> <spring:message code="sdh.sol.fac"/></label>         <form:radiobuttons path="sdh.iesdfact" items="${lista_facturas}" /> 

aplication code: java code:

 public static map<string,string> cargarfacturas(messagesource messagesource, locale locale) {        map<string,string> listafacturas = new hashmap<string,string>();        listafacturas.put("1","sin facturas”);        listafacturas.put("2","facturas requeridas”);        listafacturas.put("3","con facturas”);     return listafacturas;     }      @requestmapping("/alta")     public string alta(model model, httpservletrequest request, locale locale)throws exception{       altaform altaform = new altaform();                      model.addattribute("lista_facturas",utilidades.cargarfacturas(messagesource, locale));       model.addattribute("altaform", altaform);       return "alta";     }    

if want maintain order added entries in cargarfacturas method change map implementation hashmap linkedhashmap.when iterate through map values hashmap not retrieve elements in order in inserted. values fetched in random manner.

use

map<string,string> listafacturas = new linkedhashmap<string,string>(); 

instead of

map<string,string> listafacturas = new hashmap<string,string>(); 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -