Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
JDK 1.4 and 5
Description
OGNL doesn't allow property accessor methods to have a return type other than VOID.
This is an issue for us, as we use return types to create fluent interfaces.
What I mean by this, is that our object most often have properties that look like this:
public class User {
private String userName;
private String password;
public String getPassword()
{ return password; }public User setPassword(String password)
{ this.password = password; return this; }public String getUserName()
{ return userName; }public User setUserName(String userName)
{ this.userName = userName; return this; }}
Note: The return type might now always be the same as the surrounding type (User). It depends on what kind of interface you're trying to create.
With interfaces/classes like this we can for instance write: new User().setUserName("whatever").setPassword("secret");
From a quick glance at the OGNL code, it seems that it's that it's the "findObjectIndexedPropertyDescriptors()" method in OgnlRuntime that's causing the problem.
Would you consider allowing setter property method to have a return type other than VOID?
/Jeppe