Skip to content

Lenient property name casing (beyond standard JavaBeans conventions) [SPR-6491] #11157

Closed
@spring-projects-issues

Description

@spring-projects-issues

Stefan Schmidt opened SPR-6491 and commented

Problems arise when using MVC form-objects are bound through the data binder when the fields use 'unusual' capitalizations:

class Book {
     String Title;
     String ISBN;
     int nInStock;
     public String Book.getTitle() { ... }
     public void   Book.setTitle(String Title) { ...  }

     public String Book.getISBN() { ... }
     public void   Book.setISBN(String ISBN) { ... }

     public int    Book.getNInStock() { ... }
     public void   Book.setNInStock(int nInStock) { ... }
}

Only the following representation of these fields in a MVC form works:

<form:input path="title" />
<form:input path="ISBN" />
<form:input path="NInStock" />

Note, the Title needs to be lowercased whereas ISBN needs to remain uppercase (ie iSBN raises a NotReadablePropertyException). Same for the nInStock field which needs to be uppercased (first letter) and nInStock would raise a NotReadablePropertyException).

This seems to be inconsistent w/r to the conventions used here. Why is title handled different to the other two? Also, why can't we allow a convention where title, iSBN and nInStock all work assuming that the get methods follow JavaBean conventions with correct accessors and mutators as shown above? The data binder would just uppercase the first letter of the form field and prepend get and set accordingly.

Maybe I am missing a pattern here but this seems to be handled very inconsistently.


Affects: 3.0 RC3

Issue Links:

Referenced from: commits 388edd7

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions