spring-webflow
spring-webflow copied to clipboard
Custom binding property enhancement [SWF-913]
eli willaert opened SWF-913 and commented
When you want to use a custom converter for a property you can specify this in the binding tag of your web flow definition. This however forces you to declare all properties that can be bound. For simple beans this is not a problem but if you have a composite bean with lots of properties or dynamic properties (arrays, lists) this doesn't work. I propose that you can use wildcards when defining these bindings.
Pseudo code example:
Code:
User{ String name; Date date; User parent; Cars[] cars; }
Binding in webflow
<binder> <binding property="parent."/> <binding property="cars."/> <binding property="date" converter="shortDate" required="true"/> <binding property="name" required="true"/> </binder>
Result: All properties of the parent and cars object can be bound and some properties can explicitly be defined.
I already have this working in my code but would like to propose this as an enhancement to the current implementation.
Affects: 2.0.3
Attachments:
- EnhancedMvcViewFactoryCreator.zip (9.46 kB)
Issue Links:
- #320 Custom binding property enhancement
5 votes, 7 watchers
Oliver Drotbohm commented
In MVC this seems to work by using setAllowedFields(…) using cars[]. or cars[*].color if you want to be more specific. Unfortunately AbstractMvcView does not use MVC DataBinder infrastructure that supports wildcards and does a contains check between binding expressions and actually available parameters in the request, which of course does not work for collections and arrays.
@Eli
: Is there a chance you provide your changes as patch, so that we have some kind of starting point to debate?
Regards, Ollie
PS: I just found #320, which seems to address exactly the same issue.
eli willaert commented
@Oliver
Gierke
In attachment you can find the code I used to fix this in my project. The implementation given in #320 is much better but this worked for me at the time. This was implemented for spring webflow 2.0.6, upgrading to a higher version is a problem since those core classes are modified a lot.