SWF: 2.2.1
Spring: 3.0.5
I have the following problem: when I retrieve an object everything is bound correctly except a value dislplayed in a <form:options> tag. i.e. when I create the view and the underlying object is persisted, everything works ok, but when I retrieve the object, the first value in the drop.down is displayed instead of the correct one. The docs say that <form:options> should take care of this.
It is a mixed MVC and Spring Web Flow application.
I have registered a Formatter like so:
webmvc-config.xmlCode:@Component public class InstitutionFormatter implements Formatter<Institution> { @Autowired private InstitutionDao institutionDao; @Override public String print(Institution object, Locale locale) { System.out.println("QQQ-print: " + object.getId()); return String.valueOf(object.getId()); } @Override public Institution parse(String text, Locale locale) throws ParseException { if(text == null) { return null; } else { System.out.println("QQQ-parse: " + text); return institutionDao.findById(Long.valueOf(text)); } } }
webFlow-config.xmlCode:<mvc:annotation-driven conversion-service="applicationConversionService"/> <!-- Conversion services --> <bean id="applicationConversionService" class="se.kmh.edudb.web.propertyeditor.CustomFormattingConversionServiceFactoryBean"/>
This is according to the docs. The formatter factory:Code:<webflow:flow-builder-services development="true" id="flowBuilderServices" view-factory-creator="mvcViewFactoryCreator" conversion-service="defaultConversionService"/> <bean id="defaultConversionService" class="org.springframework.binding.convert.service.DefaultConversionService"> <constructor-arg ref="applicationConversionService"/> </bean>
Still the <form:options> doesn't do its job to bind correctly when I display. Does anybody know why, and what are the alternatives? Plain old <c:forEach> ?Code:public class CustomFormattingConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { @Autowired private InstitutionFormatter institutionFormatter; @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); registry.addFormatterForFieldType(Institution.class, institutionFormatter); } }


Reply With Quote