commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cheong Chung Onn <chung...@hs-integrating.com>
Subject Re: [Betwixt] Options for doing a roundtrip
Date Mon, 02 Feb 2004 03:20:57 GMT
Thanks robert,

I have learnt that Betwixt is bean centric the hard way over the last 
few days and i have "opened" all the Interface classes. Even though I 
have been working round the clock trying to work around Betwixt's  bean 
centric-ism but am defeated, I still find Betwixt very interesting, 
flexible and powerful.

I have only one last struggle with Betwixt, actually i have given up 
since early this morning, but i wonder if you can help point  me to the 
right direction. Here's my problem - Betwixt seems to favor xml files 
that are attribute based, hence any Custom Class Creator (subclass of 
ChainBeanCreator) can only access the "elements" that are  in the form 
of "attributes"  via mappingElement.getAttributes(). Is it possible for 
me to access the child element values during the call back to the 
CustomCreator class? I don't seems to able to find a solution, i tried 
navigating the elementDescriptor, the readContext but failed.  I only 
managed to access the definition of the bean type but not the content. 
Could you kindly advise me if there is a way to access the contents of 
the child element - <age> content as shown below during the CustomClass 
callback?

<person age=21 />  // age can be access via 
mappingElement.getAttributes.getValue("age")

<person>
	<age>21</age>  // Is the content of <age> reachable from 
CustomClassCreator?
</person>

Thanks once again.
Chung-Onn

On 2 Feb 04, at 7:19 AM, robert burrell donkin wrote:

> On 30 Jan 2004, at 09:21, Cheong Chung Onn wrote:
>
>> Hi all,
>>
>> I am using Betwixt to do object persistence, I am facing some 
>> challenges using it. Essentially,  I have to "open up" my class 
>> Interface in order to achieve the desire behavior from Betwixt? I 
>> would appreciate any one could direct me to the  right way to this 
>> problem. Below is my scenario
>>
>>  I have a class Person which has an attribute "address" type 
>> AddressIntf. The implementation of AddressIntf is Address.  Address 
>> has both the getters and setters of all its attributes, but 
>> AddressIntf only has the getters. When i map the object to xml using 
>> Person instance, i got the expected output.  However when i try to 
>> map it back to a Person instance,  i only have an uninitialized 
>> address instance. Note I've a custom class creator  to create an 
>> instance of Address.  In order to achieve the desire result i.e. the 
>> address instance attributes being updated, i would have to "open-up" 
>> the AddressIntf  by adding the setter methods. Is there any way 
>> around this problem?
>
> betwixt is start-from-java and concentrates on java beans so most of 
> the methods are geared around object models composed of java beans. 
> so, it's more difficult to map objects which are not java beans. 
> adding support for designs which are not typical use cases for object 
> models composed of java bean is not a priority for me. (of course, if 
> some developers wanted to step up who were more interested in adding 
> these features then i'd be willing to give help and directions.)
>
> one possibility which others have found useful in the past is to 
> create and register (in the XMLIntrospector.getRegistry) custom 
> XMLBeanInfo's which contain a custom updater (MapEntryAdder is an 
> example of this kind of updater).
>
> - robert
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


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


Mime
View raw message