commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Sanders" <ssand...@nextance.com>
Subject RE: [Digester] How can Digester create objects whose class is defined in the XML?
Date Mon, 04 Mar 2002 21:26:51 GMT
Martin,

You are going to have to create an ObjectCreationFactory which can look
up the object stack to the object created at the 'action-mappins' level,
and use a property of that object to create the action objects.

Basically, you need to set the type at the action-mapping level, and
then the ObjectCreationFactory that you create can digester.peek() to
get the value it needs,

Cheers,
Scott Sanders

> -----Original Message-----
> From: Martin Cooper [mailto:martin.cooper@tumbleweed.com] 
> Sent: Saturday, March 02, 2002 11:41 PM
> To: commons-dev@jakarta.apache.org
> Subject: [Digester] How can Digester create objects whose 
> class is defined in the XML?
> 
> 
> I need to be able to specify the class to be instantiated for 
> an element from an attribute on its parent element. For 
> example, I need to have Digester handle the following:
> 
>   <action-mappings type="com.foo.bar.MyClass">
>     <action ... />
>     <action ... />
>   </action-mappings>
> 
> Here, each ObjectCreate for an <action> element needs to 
> create an object of the class specified by the 'type' 
> attribute of the <action-mappings> element. After the object 
> has been created, its own attributes would be populated using 
> addSetProperties(). There is no object created for the 
> <action-mappings> element.
> 
> I have a feeling that this is going to involve a 
> FactoryCreateRule of some sort. However, I haven't quite got 
> my head around this type of rule yet to figure this out.
> 
> Ideas, anyone?
> 
> Thanks!
> 
> --
> Martin Cooper
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:commons-dev-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <mailto:commons-dev-help@jakarta.apache.org>
> 
> 

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message