From: Mark C. <mcr...@ma...> - 2006-03-09 17:24:54
|
On 2006-03-09 04:37, Marc Palmer wrote: > Well, what doesn't quite make sense (but I like it anyway) is that > WebMacro assumes the first letter of properties should be capitalized - > I think that is your real problem. > i.e. in any code that uses introspection and the java bean > specification, a property called "title" is accessed as "title" - this > is true of languages such as Groovy also. > However WM, for some reason - I imagine aesthetics - requires you to > access a property like this as "Title". As far as I recall it doesn't > matter whether you have a getTitle() or a public "title" field, it must > always be accessed as "Title". > This has always jarred slightly in terms of my 'Java programmer' > expectations, but of course to non-Java end-users of WM this may not be On 2006-03-09 11:10, Keats Kirsch wrote: > Actually you're not completely correct. A public variable name > "title" would be referred to as $obj.title. This is the point Eric > was trying to make; WM allows you to be completely unambiguous about > the property you are referring to. You can have a fields called > "title", "Title", "TITLE", or accessors called "gettitle", > "getTitle", getTITLE". So the reason you refer to a property as > "Title" is that you are generally referring to the "getTitle" > accessor, not the non-public "title" member variable. Maybe this is one of those places were an annotation might be useful for those who use Java 1.5. If you have some field accessor method that, for some reason, you can't name as getAccessor then a standard annotation indicating that it is a getter could be used to still allow the template author, who may not understand such subtleties, to use the simple reference as if it did follow the old style javabean naming convention. This is just a suggestion... I don't have any burning need for such a feature, but thought I'd run it up the flag pole and see if anyone salutes. Also, I'd be interested in knowing if it's possible to do something like this in a way that doesn't break for users of older versions of the Java. |