Hi Sriram,
sriram v wrote:
>
> Hi,
>
> I have a class like -
>
> class PlaceInfo {
>
> Address homeAddress;
>
> Address officeAddress;
>
> }
>
> I serialize the xml as -
>
> <address type="home"></address>
> <address type="office"></address>
This is what you get when you serialize a PlaceInfo instance? Sorry, but I
don't buy this ...
> Basically I made a 'AddressConverter' class extending JavaBeanConverter
> with adding the 'type' attribute in the 'marshal' function.
What type is your converter actually handling and what does it in the
marshal method?
> When I try to 'unmarshal' this xml, the 'AbstractReflectionConverter'
> kicks in and raises 'ConversionException' saying that it can't find
> 'address'
> field in the 'PlaceInfo' class. I can see why it is trying to do this.
Because PlaceInfo has no field named "address". Therefore the converter for
the PlaceInfo instance does not know, what "address" means at all.
> How do I tell the 'unmarshal' function to look for 'homeAddress' or
> 'officeAddress' using the xstream configuration?
You cannot. If you really want to have the PlaceInfo element in your XML to
contain two elements named "address", you'll need a custom converter for
PlaceInfo.
> I can make an 'Address'
> object in the 'unmarshal' function and return it but it still gives the
> same error.
You will have to create an Address instance, but I simply guess your
unmarshal method is not even called.
So, did you read and understand the converter tutorial?
Regards,
Jörg
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email