DataBinging ID vs id?

20 views
Skip to first unread message

MJ

unread,
Mar 28, 2017, 8:09:49 AM3/28/17
to Play Framework
If I define form class like this:

public class Something{

 
@Constraints.Required
 
public Long ID;
}

and use this in controller like this:

Form<Something> vyhladavanie = formFactory.form(Something.class).bindFromRequest();

I am getting this error:

Caused by: org.springframework.beans.NotRadablePropertyException: Invalid property 'ID' of bean class [controllers.Something]: Bean property 'ID' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

When I change class to this:

public class Something{

 
@Constraints.Required
 
public Long id;
}

Then everything is working correctly..Why is this happening? I even tried on empty project with same result.

Brian Smith

unread,
Mar 28, 2017, 9:00:48 AM3/28/17
to play-fr...@googlegroups.com
Hi

The underlying binding [1] is done by Spring.

Spring expects bean properties to follow Java Beans naming conventions [2].  

This means lowerCamelCase.

It is slightly confusing when using abbreviations like ID which would usually be in uppercase as names or prefixes for names, but the convention is still lowerCamelCase.

Cheers

Brian



--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/65e3bba1-8599-4357-a73d-d5577ba9e4d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages