Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

typesafe and refactoring friendly bean binding alternative to jGoodies?

843810Feb 19 2008
I've just read some jGoodies docs. It seems poewrful but it does have a problem: property names have to be specified as strings, so the compiler cannot enforce static type checking and refactoring becomes a nightmare.
PropertyConnector pc = new PropertyConnector(bean, "value", uicomp, "value");
I'm surprised no one has invented something better yet, and I hope it was my fault when I searched for it. I mean, if you can get a Class reference from the language with
MyBean.class;
it seems obvious you could do the same also with field members of a class, something like:
java.lang.reflect.Field myBeanProp = MyBean.fieldname.field;
I understand that this would require the compiler to understand each field name as a keyword, and also that the above syntax is somewhat ambiguous, but I guess those problems can be worked around by using a new single fixed operator with two arguments, name it "property", something like the instanceof operator. I imagine something like:
java.lang.reflect.Field myBeanProp = MyBean property fieldname;
This way refactoring can take place with standard IDEs tools and the Field instance has more chances to carry enough static type informations than a String so that the compiler can enforce type checking.

Do you know if something like this already exists? Do you know if JSR 295 is going to address these issues? If it does not, what do you think about this idea?

Your feedback is very appreciated.

Lucio.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 18 2008
Added on Feb 19 2008
0 comments
112 views