Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for form submissions with field names that follow JavaScript object notation [SPR-9244] #13882

Closed
spring-projects-issues opened this issue Mar 15, 2012 · 3 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Mar 15, 2012

Keith Donald opened SPR-9244 and commented

JavaScript/Ajax frameworks such as jQuery serialize Javascript Objects as form parameters using indexed object notation (because in JavaScript, every object acts like a map). For example, the following JS object:

var object = {
  connection : {
    provider: 'facebook',
    user_id: 1256789,
    access_token: 'foo'
  }
}

Gets serialized as form parameters:

connection[provider]=facebook&connection[user_id]=1256789&connection[access_token]=foo

It would be helpful if this format could auto-bind to the root form object's 'connection' property of type JavaBean, which would have nested properties 'provider', 'userId', and 'accessToken'. JSR303 validation could then be easily run against that nested bean's properties for example. BeanWrapper can only map the above to a loosely typed Map now--I have to convert to a strongly typed JavaBean manually.


Affects: 3.1.1

Issue Links:

  • #13880 Provide a way to customize the names of JavaBean properties when they're read and written for data binding purposes

Referenced from: commits spring-attic/spring-framework-issues@4810d5b, spring-attic/spring-framework-issues@4b7474b, spring-attic/spring-framework-issues@4c4b3ef

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Mar 16, 2012

Rossen Stoyanchev commented

Keith, a very minimal project at the issue repository would be very helpful.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 31, 2012

Rossen Stoyanchev commented

Corrected the example variable above to match the resulting serialized form.

Although BeanWrapperImpl can map the above to a Map, the more general syntax can include more deeply nested objects. I've created an issue project. The README page contains the output of more examples.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jul 18, 2012

Rossen Stoyanchev commented

Since POST and PUT tend to send data in the body of the request, the jQuery .serialize() function is useful mainly for GET requests. Even there having serialized data as request parameters is convenient for simple cases but can get quite ugly (see some of these "extreme" examples).

@spring-projects-issues spring-projects-issues added status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants