Details
-
Type:
Bug
-
Status: Resolved
-
Priority:
Critical
-
Resolution: Incomplete
-
Affects Version/s: 2.4.0.M1
-
Fix Version/s: None
-
Component/s: Binding: Type Conversion System
Description
First sorry for my english; I hope you can understand the problem.
*************************
I have a List<Nazioni> returned by:
public List<Nazione> getNazioni();
*************************
I have a formatter:
public class NazioneFormatter implements Formatter<Nazione> { @Autowired private INazioneGateway nazioneGateway; @Override public String print(Nazione nazione, Locale locale) { if (null == nazione) { return null; } return nazione.getCodice(); } @Override public Nazione parse(String codice, Locale locale) throws ParseException { Nazione nazione = null; if (StringUtils.isNotEmpty(codice)) { try { nazione = nazionegateway.getnazione(codice); } catch (gatewayexception e) { } } return nazione; } }
*************************
In my flow xml I defined:
<view-state id="anagrafica" view="anagrafica" model="datiAnagrafici"> <on-entry> <evaluate expression="datiAnagraficiController.datiStatici.getNazioni()" result="flowScope.nazioniList"/> </on-entry> <transition on="salva" to="anagrafica" bind="true" validate="true"> <evaluate expression="datiAnagraficiController.salva(flowScope.datiAnagrafici, flowRequestContext, messageContext, externalContext.locale)" /> </transition> </view-state>
*************************
In my jsp:
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form"%> <cut> ... </cut> <sf:select path="nazioneResidenza" data-bind="event: { change: nazioneResidenzaChanged }" class="required" > <sf:option value=""><spring:message code="generale.tendina.vuota" text="generale.tendina.vuota" /></sf:option> <sf:options items="${nazioniList}" itemValue="codice" itemLabel="descrizione"/> </sf:select>
'data-bind="event..."' is used by Knockout, but it is not important now.
*************************
The problem is: when the page is showed, NazioneFormatter.parse() is called for every Nazione object. I was expected that NazioneFormatter.parse() will be called only after submit.
Also NazioneFormatter.print() is called for every Nazione object, but I suppose it is correct because the JSP need the String "codice" to put in the <select value="">.
*************************
To completeness:
<springframework-version>3.2.2.RELEASE</springframework-version> <springsecurity-version>3.1.0.RELEASE</springsecurity-version> <webflow-version>2.4.0.M1</webflow-version>
Thanks,
Daniele