Yes, and this is why I always advise against directly binding to
lastResult, it is hard to debug.  If you bind to an instance variable,
and then use a result handler function to assign the event.result
(properly cast) to that variable, you have the opportunity within that
handler to examine the structure of your data.  It might not be exactly
as you think, and you must be exact in your references into it.  If you
are using e4x XML, toXMLString() will show you precisely what you have.

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of ben.clinkinbeard
Sent: Tuesday, December 19, 2006 8:45 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: seeding arraycollection from a web service

 

It depends on the structure of the data returned by your WS. Most of
them contain a top-level object above any array-like structure, so you
may need to do something like this:

<mx:ArrayCollection id="myProvider"
source="{wsAlice.findUsers.lastResult.nameObject}"/>

HTH,
Ben

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, <[EMAIL PROTECTED]> wrote:
>
> Hello all,
> 
> I believe I'm following the docs precisely (the "Binding a
> result to an ArrayCollection object doc" in the Flex IDE
> Help), but my app isn't working. What I'd like to do is map
> the results of a web service call into an ArrayCollection, but
> the ArrayCollection comes up empty when I try. 
> 
> My app (below) demonstrates this problem, but unfortunately
> all of my data is password protected and I can't open it up.
> Here's what you'd see if you had access: When you enter an id
> into the box, the grid marked "Uses the data provider
> directly", the Name data is populated as it should be. But the
> one that is supposed to be populated by my ArrayCollection is
> empty. 
> 
> Can anyone comment on how to map the data from a web service
> into an ArrayCollection?
> 
> -Kaylea
> 
> <?xml version="1.0" encoding="utf-8" ?>
> 
> 
> <mx:Application xmlns:af="*"
> xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " layout="absolute"
> width="960">
> 
> <mx:Script>
> <![CDATA[
> import mx.controls.Alert;
> import mx.utils.ArrayUtil;
> import flash.events.*;
> 
> public function
> submitFindUserHandler(event:MouseEvent):void {
> var temp:String = new String();
> temp = lookup.text;
> wsAlice.findUsers.send(temp, "");
> }
> ]]>
> </mx:Script>
> 
> <mx:WebService id="wsAlice" showBusyCursor="true"
> destination="wsAlice"
>
wsdl="https://parakeet.uchicago.edu:8443/ReservationsWebService/Reservat
ionsWebService?wsdl
<https://parakeet.uchicago.edu:8443/ReservationsWebService/ReservationsW
ebService?wsdl> "
> useProxy="false">
> <mx:operation name="findUsers">
> <mx:request>
> <userName></userName>
> <name></name>
> </mx:request>
> </mx:operation>
> </mx:WebService>
> <mx:ArrayCollection id="myProvider"
> 
> source="{mx.utils.ArrayUtil.toArray(wsAlice.findUsers.lastResult)}"/>
> 
> <mx:Panel x="95" y="69" width="646" height="435"
> layout="absolute">
> <mx:DataGrid x="10" y="206"
> dataProvider="{wsAlice.findUsers.lastResult}">
> <mx:columns>
> <mx:DataGridColumn headerText="First Name"
> dataField="firstName"/>
> <mx:DataGridColumn headerText="Last Name"
> dataField="lastName"/>
> </mx:columns>
> </mx:DataGrid>
> <mx:DataGrid x="345" y="206" dataProvider="{myProvider}">
> <mx:columns>
> <mx:DataGridColumn headerText="First Name"
> dataField="firstName"/>
> <mx:DataGridColumn headerText="Last Name"
> dataField="lastName"/>
> 
> </mx:columns>
> </mx:DataGrid>
> <mx:TextInput x="92" y="96" id="lookup"/>
> <mx:Text x="260" y="98" text="CNetID"/>
> <mx:Button x="92" y="126" label="Look It Up"
> click="submitFindUserHandler(event)"/>
> <mx:Text x="21" y="180" text="Uses the data provider directly"/>
> <mx:Text x="324" y="180" text="Uses a variable copy of the
> data provider"/>
> </mx:Panel>
> 
> </mx:Application>
>

 

Reply via email to