-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
Keith Donald opened SPR-6033 and commented
Grails, SpEL, and the new PresentationModel under development for 3.1 all include this feature. We should consider building this natively into DataBnder to benefit existing users & so Grails particularly no-longer has to maintain its own extensions.
Scenario illustrating feature behavior:
- Suppose I have an instance of type Foo
- And I attempt to bind to indexed property path bar.baz[0] = 'hello'
- If baz, a List, is null, it will be created in line with the rules described in Data Binder: Add support for auto-instantiating null values in nested paths [SPR-6032] #10701; 'hello' will then be added as the first element at index = 0, even though the new list was initially empty with a size of 0.
Alternate scenario:
- Attempting to bind to index property path bar.baz[5] = 'hello'; say baz is not null, but only has a size of 1 at index = 0.
- In this scenario, new default instances of the List's parameterized type e.g. String in the case of List<String> will be added at index 1..3; baz[4] would then be set to 'hello'.
As a developer, this frees me from having to pre-populate a indexed object graph ahead of time when binding back a Form post; I can simply rely on what the client is submitting to drive the population of the object graph. This is convenient
Affects: 3.0 M4
Issue Links:
- DataBinder should be able to define a different strategy for BeanWrapperImpl how autogrowing should handle gaps in collection properties [SPR-7842] #12498 DataBinder should be able to define a different strategy for BeanWrapperImpl how autogrowing should handle gaps in collection properties
- mvc: Dynamic List use case - allow collections/arrays to grow [SPR-4728] #9405 mvc: Dynamic List use case - allow collections/arrays to grow
Referenced from: commits 3fa533d
1 votes, 2 watchers
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement