commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <>
Subject Re: [Betwixt] Map of child bean
Date Thu, 13 Mar 2003 19:31:09 GMT
On Thursday, March 13, 2003, at 08:37 AM, Maksimenko Alexander wrote:

> From Overview
> ----сut  begin --
> Note that the .betwixt file specifies the mapping for a single bean. So, 
> whilst you can add extra elements (as above), it can't be used to specify 
> to names for child beans through nesting element elements.
> ----- cut end --
> I think that it is not comfortable.

yep. (the paragraph is telling you about a known deficiency.) it's a 
feature which needs to be added to betwixt. if this is a particular itch 
then i'd be glad to give you help if you wanted to volunteer to create a 

> For example i have two beans A and B.
> class A{
> private B initValue;
> private B finishValue;
> }
> class B{
> private int foo;
> bar int bar;
> }
> How can i map this bean at that xml file
> <a>
>  <init-b foo=".." bar="..."/>
>  <finish-b foo=".." bar="..."/>
> </a>

the first thing i need to point out is that betwixt is based on 
introspection and so deals in properties (rather than fields).

so if you have

class A
B getInit()
B getFinish()

then you should be able to produce the xml you need by creating a .betwixt 
file with mappings for those properties. i think you should be able to do 
something like:

<?xml version='1.0?>
<info primitiveType='attribute'>
<element name='a'>
	<element name='init-b' property='init'/>
	<element name='finish-b' property='finish'/>

if you can't make this work, post again with details of the properties and 
your betwixt file and i'll take a look in more detail.

where betwixt falls down is that you can't specify deep custom mappings 
for beans two or three levels deep in the output tree.

- robert

View raw message