java - How to Register Custom Converters in Spring 3? -
i have 2 custom converters implement twowayconverter , propertyeditor. try use them following exception :
caused by: org.springframework.binding.convert.conversionexecutornotfoundexception: no custom conversionexecutor found id 'customconverter1' converting sourceclass [java.lang.string] targetclass [java.util.arraylist]
my configuration file looks :
.... <!-- creates xmlflowregistryfactory bean --> <flow:flow-registry id="flowregistry" flow-builder-services="flowbuilderservices"> <flow:flow-location-pattern value="classpath:/com/example/web/flow/**/*.xml"/> </flow:flow-registry> <bean id="conversionservice" class="com.example.web.converter.myconvertionservice"/> <alias name="conversionservice" alias="integrationconversionservice"/> <flow:flow-builder-services id="flowbuilderservices" view-factory-creator="viewfactorycreator" conversion-service="conversionservice"/> ....
the xml i'm binding converters :
<!-- edit--> <view-state id="someid" view="someviewpath" popup="true" model="somemodel"> <binder> <binding property="companies" converter="customconverter1"/> <binding property="languages" converter="customconverter2"/> <binding property="countries"/> <binding property="useautomatchsuppliers"/> </binder> ... </view-state>
myconvertionservice.java
public class myconvertionservice extends defaultconversionservice implements applicationcontextaware { protected void adddefaultconverters() { super.adddefaultconverters(); //custom string date converter stringtodate std = new stringtodate(); std.setpattern( formatter.date_us_slash ); addconverter( std ); } public void setapplicationcontext( applicationcontext applicationcontext ) throws beansexception { map beansoftype = applicationcontext.getbeansoftype( astringtoobject.class ); ( object o : beansoftype.values() ) { addconverter( ( astringtoobject ) o ); } addconverter( new customconverter1() ); addconverter( new customconverter2() ); } }
how caan register custom converters of why spring not able find custom converter?
wiki
Comments
Post a Comment