ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: Nested element problem in custom task
Date Fri, 08 Jul 2005 07:28:21 GMT
see also in the manual
- http://ant.apache.org/manual/tutorial-writing-tasks.html#NestedElements
- http://ant.apache.org/manual/develop.html#nested-elements

Jan 

>-----Urspr√ľngliche Nachricht-----
>Von: Conor MacNeill [mailto:conor@apache.org] 
>Gesendet: Freitag, 8. Juli 2005 01:09
>An: Ant Users List
>Betreff: Re: Nested element problem in custom task
>
>This is expected behaviour. When the Child instance is added 
>to MyTask, it is not yet configured (i.e. its attributes are 
>not yet set) . It will be configured by the time your task's 
>execute() method is called. The normal strategy is just to 
>accumulate the Child objects in a collection and only use them 
>in the execute() method.
>
>If you must have the Child elements configured before being 
>given to your task, change the name of the addChild() method 
>to addConfiguredChild(). Ant will then configure the Child 
>elements before passing them to your task.
>
>Conor
>
>
>Gilles QUERRET wrote:
>> Hello,
>> 
>> 
>> Short story : I have an issue when adding a child element to its 
>> father
>> : child's attribute are not set when in addChild(Child 
>element) method...
>> 
>> -- build.xml fragment --
>> <MyTask>
>>   <Child attribute="value" />
>>   <Child attribute="value2" />
>>   ...
>> </MyTask>
>> 
>> In the classfile for Child, there's a setAttribute(String) method.
>> In the classfile for MyTask, there's a addChild(Child) method.
>> When the task is run, I enter the addChild method, with a newly 
>> created Child object, but attribute's value is null.
>> 
>> Question : is this the normal behavior ? I just want to create a 
>> HashMap with this attribute as a key, and the Child object as value. 
>> Or is there  another place where I should create my HashMap ?
>> 
>> Thanks
>> 
>> Gilles QUERRET
>> http://pct.sf.net
>> 
>> PS : please also CC me, I'm not a ant-user subscriber.
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
>additional 
>> commands, e-mail: user-help@ant.apache.org
>> 
>> 
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
>additional commands, e-mail: user-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message