From: "Christian Sell" <[EMAIL PROTECTED]> > Dominique Devienne wrote: > > -----Original Message----- > > From: Christian Sell [mailto:[EMAIL PROTECTED]] > > Sent: Monday, January 20, 2003 12:13 PM > > To: Jakarta Commons Users List > > Subject: Re: [jelly] taglib implementation questions > > > > Dominique Devienne wrote: > > > >>Ant does not use setMyAttr(SomeType) for nested elements, just for > >>attributes, and requires a SomeType(String) Ctor when an 'myattr' > > > > attribute > > > >>is found. > > > > > > ?? What would the String argument to the constructor be? > > [DD] How about the attribute value ;-) > > I still dont see what constructor you are talking about. I think the ant > docs are quite clear on this, I've included them for reference below. In > summary, if you provide an addXxx(XClass x) method, Ant will instantiate > the object using the no-arg constructor. Attributes will be set the > usual way, using the setXX methods on the nested elements. > > > IMO, it would be nice if the bean tag was able to find the nearest > parent element that implements BeanSource, and from there proceed > according to the ant rules (see below) and instantiate nested elements > directly. All that would be required of the outermost element is to > implement BeanSource and an appropriate addXX method. No library > inheritance or tag registration.
Agreed. It should be pretty easy to do - fancy having a go? The existing BeanTag and BeanPropertyTag do almost all you need - we'd just need the BeanPropertyTag to be able to optionally support addFoo(Foo) methods by invoking the no-arg constructor of Foo - right now it just uses the createFoo() pattern. Then you could create your own library, reuse the BeanTag if you wish for all your 'root' elements (the BeanSource tags) and then BeanPropertyTag can handle all the nested properties. > from ant user manual: > ... > Now you have a class NestedElement that is supposed to be used for your > nested <inner> elements, you have three options: > > 1. public NestedElement createInner() > 2. public void addInner(NestedElement anInner) > 3. public void addConfiguredInner(NestedElement anInner) > > What is the difference? > > Option 1 makes the task create the instance of NestedElement, there are > no restrictions on the type. For the options 2 and 3, Ant has to create > an instance of NestedInner before it can pass it to the task, this > means, NestedInner must have a public no-arg constructor. This is the > only difference between options 1 and 2. BTW there looks like a typo in the above; NestedInner -> NestedElement. James ------- http://radio.weblogs.com/0112098/ __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
