From: <kea...@na...> - 2002-11-15 16:24:06
|
Paul, This question has come up from time to time over the years. Probably the documentation is a bit unclear. (Maybe we should add this to the FAQ page.) WebMacro follows the JavaBean naming conventions for figuring out how to evaluate a property in a WM Script. However, it doesn't follow the naming convention in the WMScript language. The design goals of Java and WMScript are very different. Since Java is object oriented and seeks to promote encapsulation and data hiding, property access is generally through setters and getters (accessors and mutators). WMScript hides this complexity -- a property is just a property, you don't need to know if it is a public member variable, an accessor, or a key in a Map. This style mismatch may be a bit confusing, but it does have some advantages. For one thing, unconforming properties can still be accessed. I.e., getprop() could be accessed as $var.prop. But mostly I think its just a aesthetic thing: Justin and the other progenitors of WebMacro thought that $var.Prop looked better than $var.prop. Anyway this was a very early design decision that has been in every version of WebMacro (and Velocity) that I am aware of, and I don't see any compelling reason to revisit it now. Keats > -----Original Message----- > From: web...@li... > [mailto:web...@li...]On Behalf Of Paul G. > Weiss > Sent: Friday, November 15, 2002 10:30 AM > To: web...@li... > Subject: [WebMacro-user] Case problem with Bean specification > > > Please correct me if I'm wrong, but I was under the > impression that the > Bean specification held that a property named "foo" would have > accessor methods: > > public Type getFoo() > public void setFoo(Type t) > > i.e. the letter case of the first letter of the property name reverses > itself when defining the name of the property. > > This is the pattern in all of the example code provided by Sun, as > well as the Bean Serializer in the Apache SOAP package. > > Yet, webmacro (at least 1.0.1, I haven't tried 1.1b1) seems to have > it the other way. In other words if I have a variable $var of my bean > type, webmacro will not expand $var.foo when I have the methods > indicated above, but it will expand $var.Foo. > > This seems like a bug to me, although difficult to fix in light of the > existing templates that must be out there. Perhaps webmacro > ought to try both variants, i.e. if it see $var.pname it should look > for getPname() as well as getpname() ( and I would argue that it > should be in that order). > > Comments? > -Paul Weiss > > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > Webmacro-user mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webmacro-user > |