Announcement Announcement Module
No announcement yet.
Generic TypeConverter Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generic TypeConverter

    I have a class which implements TypeConverter
    Object convertIfNecessary(Object value, Class requiredType)
    by using reflection to find a constructor for requiredType taking a single String argument and using reflection to call that constructor. I have used this approact successfully in other applications.
    I know how to register a Custom PropertyEditor for a known class. In this case I want to use the code when other TypeConverters fail. What I really want is to either
    1) Call my TypeConverter if the BeanWrapperImpl in Spring cannot convert a string to a type or
    2) Call my TypeConverter first and pass the problem to BeanWrapperImpl if my code returns null from convertIfNecessary.
    I do not want to catch and handle TypeMismatchException.

    It looks like BeanWrapperImpl is hard coded in the framework and cannot easily be subclassed which would be a good solution.
    Any bright idea??

  • #2
    I think up to 2.0 there is not much you can do except write your own extension. From 2.1 it still depends what you want to use the TypeConverter for. If you need to override the conversion behaviour when the ApplicationContext starts up, there is a built in extension point in ConfigurableBeanFactory (see