Thanks Nikhil,
So happy that is sorted as I was making some good progress on my app
until that little hiccup...

Thanks once again,

C


--- In flexcoders@yahoogroups.com, "Tuli, Nikhil" <[EMAIL PROTECTED]> wrote:
>
> This looks fine. Actually the problem with the ArrayCollection is
when the Flash Engine tries to convert an XML into object, it doesnt
requires the class structure for the response before hand and it does
that at run time.
> And when it sees a single node within a node it has no reason to
convert that to ArrayCollection.
>  
> Also this would fail for scenarios like :
>  
>  <?xml version="1.0" encoding="utf-8" ?> 
> <allUnits>
>     <unitCount>
>     4
>     </unitCount>
>     <unitType>
>         xyz
>     </unitType>
>      <unit>
>          <unitName>Bunch</unitName> 
>          <unitID>4</unitID> 
>      </unit>
>      <unit>
>          <unitName>Dozen</unitName> 
>          <unitID>2</unitID> 
>      </unit>
>      <unit>
>          <unitName>Each</unitName> 
>          <unitID>1</unitID> 
>      </unit>
>      <unit>
>          <unitName>Pound</unitName> 
>          <unitID>3</unitID> 
>      </unit>
>  </allUnits>
> 
> Thought the above xml is a valid but not a good structure, and flex
would fail to understand such response.
>  
> Best Regards, 
> 
> Nikhil Tuli. 
> Associate Software Engineer, 
> Fidelity Business Services India Pvt. Ltd., 
> 7th Floor, Tower D,
> Uni TechWorld, Sector 39,
> Gurgaon - 122 001.
> Phone (India) : +91 124 283 3209
> Phone (US): 8 804 4395 
> 
> "il n'y a rien tel que noir ou blanc, toutes sont différentes
dégradés de gris" 
> 
> "Any comments or statements made in this email are not necessarily
those of Fidelity Business Services India Pvt. Ltd. or any of the
Fidelity Investments group companies. The information transmitted is
intended only for the person or entity to which it is addressed and
may contain confidential and/or privileged material. If you have
received this in error, please contact the sender and delete the
material from any computer. All e-mails sent from or to Fidelity
Business Services India Pvt. Ltd. may be subject to our monitoring
procedures."
> 
>  
> 
> 
>   _____  
> 
>       From: flexcoders@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Carlton Dickson
>       Sent: Friday, June 08, 2007 5:33 PM
>       To: flexcoders@yahoogroups.com
>       Subject: [flexcoders] Re: Supply list with XML fails when only one
element
>       
>       
> 
>       Thanks the response... :)
>       
>       Hmmm...I gave that a shot and it seems to work...not sure if what I
>       have ended up with is the long winded approach...it works for single
>       node XML and multiple...now to just implement this approach in my main
>       application :-s
>       
>       Do you think this approach is ok?
>       
>       == Working code below ==
>       <?xml version="1.0" encoding="utf-8"?>
>       <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
>       layout="absolute" creationComplete="unitRPC.send();">
>       <mx:Script>
>       <![CDATA[
>       import mx.collections.ArrayCollection;
>       import mx.collections.XMLListCollection;
>       import mx.rpc.events.ResultEvent;
>       
>       [Bindable]
>       private var units:XML = new XML();
>       [Bindable]
>       private var unitsData:XMLListCollection;
>       
>       private function unitRPCResult(event:ResultEvent):void
>       {
>       units = (event.result as XML);
>       unitsData = new XMLListCollection(units.unit);
>       }
>       ]]>
>       </mx:Script>
>       
>       <mx:HTTPService id="unitRPC" url="../services/xml.xml"
>       result="unitRPCResult(event)" resultFormat="e4x" />
>       <mx:ComboBox id="cmbo_test" x="10" y="10" dataProvider="{unitsData}"
>       labelField="unitName"></mx:ComboBox>
>       
>       </mx:Application>
>       
>       ====
>       
>       --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> , "Tuli, Nikhil" <nikhil.tuli@>
wrote:
>       >
>       > How about changing the data type from ArrayCollection to XMLList.
>       > 
>       > Best Regards, 
>       > 
>       > Nikhil Tuli. 
>       > Associate Software Engineer, 
>       > Fidelity Business Services India Pvt. Ltd., 
>       > 7th Floor, Tower D,
>       > Uni TechWorld, Sector 39,
>       > Gurgaon - 122 001.
>       > Phone (India) : +91 124 283 3209
>       > Phone (US): 8 804 4395 
>       > 
>       > "il n'y a rien tel que noir ou blanc, toutes sont différentes
>       dégradés de gris" 
>       > 
>       > "Any comments or statements made in this email are not necessarily
>       those of Fidelity Business Services India Pvt. Ltd. or any of the
>       Fidelity Investments group companies. The information transmitted is
>       intended only for the person or entity to which it is addressed and
>       may contain confidential and/or privileged material. If you have
>       received this in error, please contact the sender and delete the
>       material from any computer. All e-mails sent from or to Fidelity
>       Business Services India Pvt. Ltd. may be subject to our monitoring
>       procedures."
>       > 
>       > 
>       > 
>       > 
>       > _____ 
>       > 
>       > From: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
>       [mailto:flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> ] On Behalf Of Carlton Dickson
>       > Sent: Friday, June 08, 2007 4:03 PM
>       > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
>       > Subject: [flexcoders] Supply list with XML fails when only one
element
>       > 
>       > 
>       > 
>       > I have some simple XML which when passed to a control is displayed no
>       > problems but when the XML only has 1 element it seems to fail.
>       > 
>       > The error I get is shown below as are my files just in case some one
>       > has a chance to test it out.
>       > 
>       > I have a few books on Flex and they don't seem to use examples where
>       > there is a piece of XML with just one child node, any ideas why this
>       > error might be occuring?
>       > 
>       > TypeError: Error #1034: Type Coercion failed: cannot convert
>       > mx.utils::[EMAIL PROTECTED] to mx.collections.ArrayCollection.
>       > at basic/::unitRPCResult()
>       > at basic/__unitRPC_result()
>       > at
>       > 
> 
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
>       > at flash.events::EventDispatcher/dispatchEvent()
>       > at
>       > 
> 
mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent
<http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent> 
>       <http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent
<http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent> > ()
>       > at
>       > 
> 
mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler
<http://www.adobe.com/2006/flex/mx/internal::resultHandler> 
>       <http://www.adobe.com/2006/flex/mx/internal::resultHandler
<http://www.adobe.com/2006/flex/mx/internal::resultHandler> > ()
>       > at mx.rpc::Responder/result()
>       > at mx.rpc::AsyncRequest/acknowledge()
>       > at ::DirectHTTPMessageResponder/completeHandler()
>       > at
>       > 
> 
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
>       > at flash.events::EventDispatcher/dispatchEvent()
>       > at flash.net::URLLoader/flash.net:URLLoader::onComplete()
>       > 
>       > === Start MXML===
>       > <?xml version="1.0" encoding="utf-8"?>
>       > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> 
>       <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > "
>       > layout="absolute" creationComplete="unitRPC.send();">
>       > <mx:Script>
>       > <![CDATA[
>       > import mx.collections.ArrayCollection;
>       > import mx.rpc.events.ResultEvent;
>       > 
>       > [Bindable]
>       > private var units:ArrayCollection = new ArrayCollection();
>       > 
>       > private function unitRPCResult(event:ResultEvent):void
>       > {
>       > units = event.result.allUnits.unit;
>       > }
>       > ]]>
>       > </mx:Script>
>       > 
>       > <mx:HTTPService id="unitRPC" url="../services/xml.xml"
>       > result="unitRPCResult(event)" />
>       > 
>       > <mx:ComboBox id="cmbo_test" x="10" y="10" dataProvider="{units}"
>       > labelField="unitName"></mx:ComboBox>
>       > 
>       > </mx:Application>
>       > === End MXML===
>       > 
>       > ===Start working XML===
>       > <?xml version="1.0" encoding="utf-8" ?> 
>       > <allUnits>
>       > <unit>
>       > <unitName>Bunch</unitName> 
>       > <unitID>4</unitID> 
>       > </unit>
>       > <unit>
>       > <unitName>Dozen</unitName> 
>       > <unitID>2</unitID> 
>       > </unit>
>       > <unit>
>       > <unitName>Each</unitName> 
>       > <unitID>1</unitID> 
>       > </unit>
>       > <unit>
>       > <unitName>Pound</unitName> 
>       > <unitID>3</unitID> 
>       > </unit>
>       > </allUnits>
>       > ===End working XML===
>       > 
>       > ===Start bad XML===
>       > <?xml version="1.0" encoding="utf-8" ?> 
>       > <allUnits>
>       > <unit>
>       > <unitName>Bunch</unitName> 
>       > <unitID>4</unitID> 
>       > </unit>
>       > </allUnits>
>       > ===End bad XML===
>       >
>


Reply via email to