I discovered that (event.result.people.person.source != null) when the result 
is an ArrayCollection.  So I used that in an if statement so I could choose 
simply to set my variable equal to the result, or if I had to 
variable.addItem() the result.

Your way is much neater.  I'll give that a try, thanks.

L.


--- In [email protected], "valdhor" <valdhorli...@...> wrote:
>
> I use "new ArrayCollection(ArrayUtil.toArray(event.result))". It works for 1 
> or more items in the result.
> 
> --- In [email protected], "Laurence" <LMacNeill@> wrote:
> >
> > I'm trying to read data from an XML file, and put that data into an 
> > ArrayCollection.
> > 
> > This works great when I have more than one "object" in the XML file.  But 
> > when there's only one "object" in there, my HTTPService RPC returns it as 
> > an Object instead of an ArrayCollection of Objects.
> > 
> > So when I assign the event.result to my ArrayCollection I get a "Cannot 
> > Convert to ArrayCollection" error message...
> > 
> > Let me give an example:
> > 
> > MyXMLFile.xml:
> > <people>
> >    <person>
> >       <firstName>Joe</firstName>
> >       <lastName>Smith</lastName>
> >    </person>
> > </people>
> > 
> > If I have more than one <person></person> pair in my XML file, then they 
> > get returned as an ArrayCollection in event.result.people.person.  But with 
> > only one <person></person> pair in my XML file, event.result.people.person 
> > is an ObjectProxy -- which can't be converted to an ArrayCollection, 
> > apparently.
> > 
> > If event.result.people had a length property, I could just loop over it for 
> > {length} number of times and addItem() each <person> to my ArrayCollection 
> > -- but I see no length property on the event.result...  So how do I get 
> > this to work?  I won't know in advance how many <person></person> pairs are 
> > in the XML file, so I can't make any assumptions about the length...  Could 
> > be 1, could be 100...
> > 
> > Is there a way to programmatically tell whether or not 
> > event.result.people.person is an ArrayCollection or an ObjectProxy?  If I 
> > could tell what it was, then I could use that information to let the 
> > program decide how to deal with it...
> > 
> > Thanks for any suggestions...
> > Laurence MacNeill
> > Mableton, Georgia, USA
> >
>


Reply via email to