Skip to content

Data Binder: Add support for auto-instantiating null values in nested paths [SPR-6032] #10701

@spring-projects-issues

Description

@spring-projects-issues

Keith Donald opened SPR-6032 and commented

Grails, SpEL, and the new PresentationModel support in development for 3.1 all have native support for this. We should consider building this capability natively into DataBinder for consistency, and so Grails no longer has to maintain its own DataBinder extension.

Scenario:
Assume we are binding to an instance of object Foo
Assume the expression of the property we are binding to is 'bar.baz', so a nested binding
If the bar property value is null, this feature will cause a new value of bar's propertyType to be created via its default constructor and set for bar.

As a developer, this alleviates me from having to make sure all the property paths are instantiated ahead of time; I can simply rely on what the client is binding along with the property metadata to drive population of the object graph. This is convenient.


Affects: 3.0 M4

Issue Links:

Referenced from: commits 3fa533d

2 votes, 3 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions