You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Benjamin de Dardel <be...@gmail.com> on 2011/11/05 08:57:27 UTC

adding dynamic element

Hi all,

I would like to add a dynamic element and instanciate it dynamically 
using 'instanceof' attribute.
Something like that :

<mytask>
<mydynamicelement instanceof="my.first.class">
<some-inner>
</some-inner>
</mydynamicelement>
<mydynamicelement instanceof="my.second.class">
<some-other-inner>
</some-other-inner>
</mydynamicelement>
</mytask>

I fail in using method : public Object createDynamicElement(String name),
because I have to return the instance of my element before parsing its 
attributes.

Do you have any idea to find a solution ?

Best regards,
Benjamin

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


Re: adding dynamic element

Posted by Stefan Bodewig <bo...@apache.org>.
On 2011-11-05, Benjamin de Dardel wrote:

> Hi all,

> I would like to add a dynamic element and instanciate it dynamically
> using 'instanceof' attribute.
> Something like that :

> <mytask>
> <mydynamicelement instanceof="my.first.class">
> <some-inner>
> </some-inner>
> </mydynamicelement>
> <mydynamicelement instanceof="my.second.class">
> <some-other-inner>
> </some-other-inner>
> </mydynamicelement>
> </mytask>

> I fail in using method : public Object createDynamicElement(String name),
> because I have to return the instance of my element before parsing its
> attributes.

> Do you have any idea to find a solution ?

None that would allow you to use an attribute as selector.  Maybe you
should revisit this requirement.  You could do something like 

<mytask>
  <my.first.class>
    <some-inner>
    </some-inner>
  </my.first.class>
  <my.second.class>
    <some-other-inner>
    </some-other-inner>
  </my.second.class>
</mytask>

or a combination of typedef/componentdef with add(Object) or
addConfigured(Object) instead.

Stefan

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