Reputation: 3912
I am using a third party library that has objects that I want to be able to edit via a Spring (version 3.2) form. The problem is that the object does not use the Java-beans naming convention because the properties can be dynamic in some cases. Instead, the objects have methods like object.getAttr("attribute_name")
and object.setAttr("attribute_name", value)
. It would be easy for me to write an implementation of BeanWrapper to wrap this type of object, because there are methods for querying what attributes are available, etc.
I also don't need custom editors because the properties are mostly built-in types. All I need is a way to customize the data binding or find some other way to plug in my custom BeanWrapper so that Spring's form tag will know how find the properties on the object when binding the form values. Seems like this should be fairly easy (that is why BeanWrapper is an interface, right?) but I am just not seeing it...
Upvotes: 3
Views: 296
Reputation: 10709
For version 3.2 you could:
BeanPropertyBindingResult
and override createBeanWrapper()
method.ExtendedServletRequestDataBinder
and override getInternalBindingResult()
method to return your bindingResult
instance.ServletRequestDataBinderFactory
and return your databinder
instance.RequestMappingHandlerAdapter
and override createDataBinder()
method.order < Ordered.LOWEST_PRECEDENCE
.So I think that you need to extends four framework classes to pull up a custom BeanWrapper
into Spring MVC.
Maybe there are simpler options.
Upvotes: 3