This is some very interesting code. I can see a great value using this code to
convert data returned by a web service into Flex objects.
Three issues come to mind.
1) I don't always construct an object from XML. Sometimes, I construct an
object with data returned from a web service, but other times, I'm just making
a new object to send TO the server. Last time I tried to overload
constructors, I got compile errors from Flex. My solution was to just make a
PopulateFromXml method that I could use when I had XML data to populate.
2) What would you do if the XML had a tag that was a reserved word? A child
named "function" for example? or "return"? In my code, I got around it by
generating Flex object from each Java object in my model, and making an XML
populator for each class. Your general purpose class is a much better solution
if I can find a clever way around the reserved word problem.
3) I think long numbers need to be in a Number, but Numbers can't be null.
When a Number
gets sent to a web service, it has the value "NaN", which can't be
deserialized on the server. Adding support for the "*" type would handle that
- just populate it with a Number if one is present, otherwise leave it
uninitialized.
Just my $.02 -- or is that $.03 }:-),
Steve
Roger Braunstein <[EMAIL PROTECTED]> wrote:
Hi there,
Tony Alves tipped me off that there was a thread about this when I posted my
article on instant binding to XML models. Feel free to use the code I present
in my approach here:
http://www.partlyhuman.com/blog/roger/instant-model-binding-with-reflection
Cheers!
Roger Braunstein
---------------------------------
Boardwalk for $500? In 2007? Ha!
Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.