Results 1 to 3 of 3

Thread: Can't register my Converter

  1. #1
    Join Date
    Jun 2012
    Posts
    3

    Default Can't register my Converter

    I'm following the example <a href="http://static.springsource.org/spring/docs/3.0.7.RELEASE/reference/validation.html#core-convert">here</a>.

    My applicationContext has the following:

    <bean id="conversionService"
    class="org.springframework.context.support.Convers ionServiceFactoryBean">
    <property name="converters">
    <set>
    <bean class="org.mypackage.MyFilterConverter"/>
    </set>
    </property>
    </bean>

    My converter looks like this:

    public class MyFilterConverter implements Converter<String, HashMap<String, List<MyClass>>> { ...

    The converter does not get registered. I tested MyFilterConverter independently and it works.


    I followed the stack trace down to GenericConversionService.getMatchableConverters(Cl ass<?> sourceType, Class<?> targetType). It seems to me that the bug is that the matchable is not added to anything. Anyway, I wasn't able to follow the code through, but it looks like there's where the thing gets lost.

    When I come back from this call, my converter is not added.

    Any ideas?

    thanks

    --
    llappall

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello

    1) Next time use code tags
    2) Post the complete error stack trace to analyze it
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #3
    Join Date
    Jul 2012
    Posts
    6

    Default

    First of all I can see the space between "Convers" and "ionServiceFactoryBean" . is that ok?
    Second what us your Converter interface? better to use "org.springframework.core.convert.converter.Generi cConverter" interface

    There are Two method signature in CustomConverter Class
    1) Set<ConvertiblePair> getConvertibleTypes()

    this method will get involved once at initialroading
    and make decision pair of conversion type for calling back later

    2)Object convert(Object source, TypeDescriptor sourceType,
    TypeDescriptor targetType)


    This method will calling back every time for proper matching

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •