Is it possible to bind a Spring Form to an Object using the constructor or by mapping multiple fields to a single value via a custom Editor?
I have an Object who's internal representation is not conducive to data en开发者_Python百科try. I have a class with multiple custom components, one of which is a Range class. The Range class is easiest to input using two text field inputs rather than as one text field that uses a custom PropertyEditor.
I have a fully functional constructor that could handle the multiple field option but I don't believe there's anyway to get Spring to use the constructor rather than setter injection. Am I wrong about that? If I'm not, is it possible to bind two form elements to a single object member using a custom PropertyEditor or some related method?
Thanks!
I don't quite see the problem, assuming your Range object has 'rangeStart' and 'rangeEnd' properties.
With one of the fields use <spring:bind path="yourObject.rangeStart">
and with the second field use <spring:bind path="yourObject.rangeEnd">
.
精彩评论