I have a use case where I need to bind a text field of a webpage to a bean which is declared as an interface type but instantiated as some Class which offcourse implements this interface.
when Spring tries to find a converter to convert the String(from the webpage) to the actual type to which it should bind it only checks how this bean is declared, not how it is instantiated. and I do not have a converter to convert the String to this interface.
Does anyone know how I can solve this problem? Maybe something with a Custom Editor?
Mark Spritzler wrote:Can you, in code figure out the class implementation to instantiate?
I have done heirarchies like that in PropertyEditors and I am sure I can do that in a Converter class too.
How do you determine what type of implementation to instantiate?
can you point me in the right direction on how to do this in a custom editor?
I think I cannot figure out what type to instantiate because the BeanWrapperImpl only gives me the sourceType and TargetType, which it retrieved trough reflection and only from the signature of the property(the interface) not the actual implementation. If somehow the BeanWrapperImpl gave me the OldValue(which does contain the actual type) then I can get the value I should bind to. But for some reason the oldValue is always null...