commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luca Borz <lb...@opera21.it>
Subject conversion with bean utils
Date Tue, 13 May 2008 09:25:08 GMT
Hi,

i'm using Beanutils in order to converter from a datalayer to another.
I have an object (e.g. Employee) in this two different datalayers, and i 
want to convert from first datalayer to the other and viceversa, and the 
last one has a different not-standard type of data, (e.g. field of type 
boolean must be converted to field of type MyCustomBollean). For this 
purpose i implements the interface Converter, and then i registered the 
converters for each type i need.
The problem is if the source field is a complex type. For example, in 
Employee i have a field of complex type Address. I want to use a 
"default" converter, that must be invoked every time that i need a 
conversion of a complex type. The problem is the input: my datalayers 
are dinamically generated, so i didn't know the complex type that i can 
get then i cannot register the converters for complex tytpe, because i 
didn't know what type of object i want (in my example, i doesn't know 
what is Address, i only know what interface Address implements). All the 
objects from one datalayers implement a specific Interface, and also th 
other datalayer has an Interface that is common for all his objects. I 
try to use a converter like that:
convertUtils.register(new ComplexTypeConverter(), ModelInterface.class) 
but it doesn't work, because it seems that beansutil cannot understand 
that the object that i want implements this particular interface, so 
beansutils dont use my converter and return an exception.
So there is any way to declare a converter for complex type, that is 
invoked any time i found a complex type, and returns as ouput an istance 
of interface that the complex type implements.


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


Mime
View raw message