Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService
Hi Tracy, apologies that it took me quite a while to reply and continue this. been sidetracked on another project. anyway, when I have passed the xmllistcollection as string to .net, what method would i use to parse the information in the .net side? thanks. regards, Angelo From: Tracy Spratt To: flexcoders@yahoogroups.com Sent: Wednesday, 8 July, 2009 12:48:27 Subject: RE: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService var sXML:String = “”; sXML += myXMLListCollection .toXMLSTring( ); sXML+= “ _ Public Function setUserPermits(ByVal sRowsXml As String, ByVal sSId As String) As DataTable … Tracy Spratt, Lariat Services, development services available From:flexcod...@yahoogro ups.com [mailto: flexcod...@yahoogro ups.com ] On Behalf Of Angelo Anolin Sent: Tuesday, July 07, 2009 8:09 PM To: flexcod...@yahoogro ups.com Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Hi Tracy, I would certainly appreciate if you could point me in the right direction on using XMLListCollection and sending it back to .NET as a string. Thanks. Regards, Angelo From:Tracy Spratt To: flexcod...@yahoogro ups.com Sent: Tuesday, 7 July, 2009 4:45:56 Subject: RE: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Why not use XMLListCollection and send the xml to .net as a string? There is little value in building an ArrayCollection of generic obects. You can sort/filter an XMLListCollection. XML is more verbose than some other methods, but if bandwidth is truly an issue, then you should be looking at a binary protocol. Tracy Spratt, Lariat Services, development services available From:flexcod...@yahoogro ups.com [mailto: flexcod...@yahoogro ups.com ] On Behalf Of Angelo Anolin Sent: Friday, July 03, 2009 2:09 AM To: flexcod...@yahoogro ups.com Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Hi Sam, Basically this is the process which I am using. .NET Retrieve records from Oracle DB and store the same into a dataset. Return the dataset as XML string via the command DataSet.GetXML. Flex In the event handler of my webservice method call, I parse the string into XML, then ArrayCollection via the following codes: private var _xmlData:XML; [Bindable] private var arrDP:ArrayCollecti on = new ArrayCollection; _xmlData = XML(event.result) ; var oTemp:Object; var xl:XMLList = _xmlData.children( ); var i:int; for(i = 0; i < xl.length(); i++) { oTemp = {NAME:xl[i]. NAME.text( ), TEAM:xl[i].TEAM. text(), JERSEY :xl[i] .JERSEY.text( ), MANAGER:xl[i] .MANAGER. text()}; arrDP.addItem( oTemp); } and in my datagrid, I am setting its dataProvider to the arrDP variable. I used Array Collection because I implemented a search and filter functionality which searches and filters the data accordingly for the dataprovider which is then reflected back to the datagrid. Now, when I need to return the ArrayCollection to .NET, I simply pass the same as a parameter to a .NET function which accepts ArrayList as parameter. .NET Once the function receieves the arraycollection (which is then now an array list), I get the arrays inside the arraylist and get the values inside the array. I think by doing things like this, it may not be the best way. You mentioned you'd map the XML to typed objects in .NET. How can I do this? Instead of using arraycollection as dataprovider in my datagrid, can I use another which would be much easier when I pass back to the .NET function? Whats the best way to interact large set of data (datasets) between .NET and Flex? Thanks a lot. From:Sam Lai To: flexcod...@yahoogro ups.com Sent: Friday, 3 July, 2009 13:52:12 Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Instead of using an array list and trying to emulate the type-less abilities of AS3, I'd try to map the XML to typed objects in .NET. Or does the XML from your Flex app differ too wildly to do this? Are you using the XmlSerializer to deserialize this? Or are you using WCF? Or are you doing it some other way, or manually? I'd provide an example, but I don't know enough details on your situation to give something useful :) 2009/7/3 Angelo Anolin : > > > Hi Sam, > > Care to show some examples? I am parsing the arrayCollection into an > ArrayList on .NET. This is particularly not too appealing since I just > discovered that for example, if one of the objects in the arraycollection > would have an empty string value, the number of items inside the array is > not reflected properly in .NET. > > Like: > > priv
RE: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService
var sXML:String = ""; sXML += myXMLListCollection.toXMLSTring(); sXML+= " _ Public Function setUserPermits(ByVal sRowsXml As String, ByVal sSId As String) As DataTable . Tracy Spratt, Lariat Services, development services available _ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Angelo Anolin Sent: Tuesday, July 07, 2009 8:09 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Hi Tracy, I would certainly appreciate if you could point me in the right direction on using XMLListCollection and sending it back to .NET as a string. Thanks. Regards, Angelo _ From: Tracy Spratt To: flexcoders@yahoogroups.com Sent: Tuesday, 7 July, 2009 4:45:56 Subject: RE: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Why not use XMLListCollection and send the xml to .net as a string? There is little value in building an ArrayCollection of generic obects. You can sort/filter an XMLListCollection. XML is more verbose than some other methods, but if bandwidth is truly an issue, then you should be looking at a binary protocol. Tracy Spratt, Lariat Services, development services available _ From: flexcod...@yahoogro ups.com [mailto: flexcod...@yahoogro ups.com ] On Behalf Of Angelo Anolin Sent: Friday, July 03, 2009 2:09 AM To: flexcod...@yahoogro ups.com Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Hi Sam, Basically this is the process which I am using. .NET Retrieve records from Oracle DB and store the same into a dataset. Return the dataset as XML string via the command DataSet.GetXML. Flex In the event handler of my webservice method call, I parse the string into XML, then ArrayCollection via the following codes: private var _xmlData:XML; [Bindable] private var arrDP:ArrayCollecti on = new ArrayCollection; _xmlData = XML(event.result) ; var oTemp:Object; var xl:XMLList = _xmlData.children( ); var i:int; for(i = 0; i < xl.length(); i++) { oTemp = {NAME:xl[i]. NAME.text( ), TEAM:xl[i].TEAM. text(), JERSEY :xl[i] .JERSEY.text( ), MANAGER:xl[i] .MANAGER. text()}; arrDP.addItem( oTemp); } and in my datagrid, I am setting its dataProvider to the arrDP variable. I used Array Collection because I implemented a search and filter functionality which searches and filters the data accordingly for the dataprovider which is then reflected back to the datagrid. Now, when I need to return the ArrayCollection to .NET, I simply pass the same as a parameter to a .NET function which accepts ArrayList as parameter. .NET Once the function receieves the arraycollection (which is then now an array list), I get the arrays inside the arraylist and get the values inside the array. I think by doing things like this, it may not be the best way. You mentioned you'd map the XML to typed objects in .NET. How can I do this? Instead of using arraycollection as dataprovider in my datagrid, can I use another which would be much easier when I pass back to the .NET function? Whats the best way to interact large set of data (datasets) between .NET and Flex? Thanks a lot. _ From: Sam Lai To: flexcod...@yahoogro ups.com Sent: Friday, 3 July, 2009 13:52:12 Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Instead of using an array list and trying to emulate the type-less abilities of AS3, I'd try to map the XML to typed objects in .NET. Or does the XML from your Flex app differ too wildly to do this? Are you using the XmlSerializer to deserialize this? Or are you using WCF? Or are you doing it some other way, or manually? I'd provide an example, but I don't know enough details on your situation to give something useful :) 2009/7/3 Angelo Anolin mailto:angelo_anolin%40yahoo.com> yahoo.com>: > > > Hi Sam, > > Care to show some examples? I am parsing the arrayCollection into an > ArrayList on .NET. This is particularly not too appealing since I just > discovered that for example, if one of the objects in the arraycollection > would have an empty string value, the number of items inside the array is > not reflected properly in .NET. > > Like: > > private var arrR:ArrayCollectio n = new ArrayCollection( [{ID:"001" , > Value:"Select" }, > {ID:"002", > Value:"Choose" }, > {ID:"003", > Value:""},]) ; > > When I pass this var arrR into a .NET webservice and delegate it to an > ArrayList, the items in the array list will have one of the arrays only > contai
Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService
Hi Tracy, I would certainly appreciate if you could point me in the right direction on using XMLListCollection and sending it back to .NET as a string. Thanks. Regards, Angelo From: Tracy Spratt To: flexcoders@yahoogroups.com Sent: Tuesday, 7 July, 2009 4:45:56 Subject: RE: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Why not use XMLListCollection and send the xml to .net as a string? There is little value in building an ArrayCollection of generic obects. You can sort/filter an XMLListCollection. XML is more verbose than some other methods, but if bandwidth is truly an issue, then you should be looking at a binary protocol. Tracy Spratt, Lariat Services, development services available From:flexcod...@yahoogro ups.com [mailto: flexcod...@yahoogro ups.com ] On Behalf Of Angelo Anolin Sent: Friday, July 03, 2009 2:09 AM To: flexcod...@yahoogro ups.com Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Hi Sam, Basically this is the process which I am using. .NET Retrieve records from Oracle DB and store the same into a dataset. Return the dataset as XML string via the command DataSet.GetXML. Flex In the event handler of my webservice method call, I parse the string into XML, then ArrayCollection via the following codes: private var _xmlData:XML; [Bindable] private var arrDP:ArrayCollecti on = new ArrayCollection; _xmlData = XML(event.result) ; var oTemp:Object; var xl:XMLList = _xmlData.children( ); var i:int; for(i = 0; i < xl.length(); i++) { oTemp = {NAME:xl[i]. NAME.text( ), TEAM:xl[i].TEAM. text(), JERSEY :xl[i] .JERSEY.text( ), MANAGER:xl[i] .MANAGER. text()}; arrDP.addItem( oTemp); } and in my datagrid, I am setting its dataProvider to the arrDP variable. I used Array Collection because I implemented a search and filter functionality which searches and filters the data accordingly for the dataprovider which is then reflected back to the datagrid. Now, when I need to return the ArrayCollection to .NET, I simply pass the same as a parameter to a .NET function which accepts ArrayList as parameter. .NET Once the function receieves the arraycollection (which is then now an array list), I get the arrays inside the arraylist and get the values inside the array. I think by doing things like this, it may not be the best way. You mentioned you'd map the XML to typed objects in .NET. How can I do this? Instead of using arraycollection as dataprovider in my datagrid, can I use another which would be much easier when I pass back to the .NET function? Whats the best way to interact large set of data (datasets) between .NET and Flex? Thanks a lot. From:Sam Lai To: flexcod...@yahoogro ups.com Sent: Friday, 3 July, 2009 13:52:12 Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Instead of using an array list and trying to emulate the type-less abilities of AS3, I'd try to map the XML to typed objects in .NET. Or does the XML from your Flex app differ too wildly to do this? Are you using the XmlSerializer to deserialize this? Or are you using WCF? Or are you doing it some other way, or manually? I'd provide an example, but I don't know enough details on your situation to give something useful :) 2009/7/3 Angelo Anolin : > > > Hi Sam, > > Care to show some examples? I am parsing the arrayCollection into an > ArrayList on .NET. This is particularly not too appealing since I just > discovered that for example, if one of the objects in the arraycollection > would have an empty string value, the number of items inside the array is > not reflected properly in .NET. > > Like: > > private var arrR:ArrayCollectio n = new ArrayCollection( [{ID:"001" , > Value:"Select" }, > {ID:"002", > Value:"Choose" }, > {ID:"003", > Value:""},]) ; > > When I pass this var arrR into a .NET webservice and delegate it to an > ArrayList, the items in the array list will have one of the arrays only > containing 1 item (instead of 2). > > Adding to my problem is the fact that the arrays inside the array list when > read in .NET should have the object ID and Value be in order but they are > not. This is further true when there are many items in the array > collection. Sometimes, the first item becomes the last one in the array > list, and sometimes the order is not well. > > In any case, I am finding a solution on how I would be able to pass an > ArrayCollection to .NET and be able to parse it properly. > > Thanks. > > __
Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService
Hi Sam Lai, THanks for the input and my apologies for replying late since I felt the need to get deeper on the issue I am encountering. In my web service, the arraycollection is received as an array list and yes, it is like an array of xml nodes. In my arraycollection, say I have 5 columns and when one of the columns contains an empty string, when I pass it to my .NET webservice, the arraylist will have an array which only contains 4 columns (instead of the expected 5). That is why the empty field is actually causing me some problems. I am trying to find some E4x documentation / article specifically tackling this kind of .NET and Flex integration. Do you know of some? Thanks and regards, Angelo From: Sam Lai To: flexcoders@yahoogroups.com Sent: Saturday, 4 July, 2009 12:54:53 Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService I just wrote up a simple C# web service that accepts an ArrayList: [WebMethod] public bool ArrayListTest( System.Collectio ns.ArrayList a) { ... } Then in Flex I wrote this, http://localhost: 63868/Service1. asmx?WSDL" id="ws"> When sendWebServiceCall is triggered, it calls the C# web service and passes the ArrayCollection to it. In the web service, the ArrayCollection is received as an array list of XmlNodes. Each XmlNode contains a node for each field, even if it is an empty string. http://tempuri. org/">808 http://tempuri. org/">bob http://tempuri. org/"> http://tempuri. org/">fred Is this anything like what you're getting? The edge case you described in another email about an empty string causing problems doesn't seem to cause problems. Also see inline. 2009/7/3 Angelo Anolin : > I think by doing things like this, it may not be the best way. > > You mentioned you'd map the XML to typed objects in .NET. How can I do > this? As you're using a dataset, this isn't really an option. A dataset as opposed to a collection of typed objects are two ways of handling data from data sources; it is arguable which way is better. The problem in your case, is that the XML generated as a result of passing an ArrayCollection to a web service method cannot be passed into the dataset's readXml method. (Even if it could by inferring a schema, it would be different to your database's schema.) The only way I know of to do seamless transfer of data without having to parse XML is to use WebORB. Otherwise you will have to parse the XML produced on both sides to re-create the dataset/object. > Instead of using arraycollection as dataprovider in my datagrid, can I use > another which would be much easier when I pass back to the .NET function? I wonder if it is possible to bind your datagrid directly to the e4x XML? That way you can pass the entire XML doc back to .NET via the web service, and hence you can re-create the dataset using dataset.readXML. > _ _ __ > From: Sam Lai > To: flexcod...@yahoogro ups.com > Sent: Friday, 3 July, 2009 13:52:12 > Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When > Passed to .NET WebService > > Instead of using an array list and trying to emulate the type-less > abilities of AS3, I'd try to map the XML to typed objects in .NET. Or > does the XML from your Flex app differ too wildly to do this? > > Are you using the XmlSerializer to deserialize this? Or are you using > WCF? Or are you doing it some other way, or manually? > > I'd provide an example, but I don't know enough details on your > situation to give something useful :) > > 2009/7/3 Angelo Anolin : >> >> >> Hi Sam, >> >> Care to show some examples? I am parsing the arrayCollection into an >> ArrayList on .NET. This is particularly not too appealing since I just >> discovered that for example, if one of the objects in the arraycollection >> would have an empty string value, the number of items inside the array is >> not reflected properly in .NET. >> >> Like: >> >> private var arrR:ArrayCollectio n = new ArrayCollection( [{ID:"001" , >> Value:"Select" }, >> {ID:"002", >> Value:"Choose" }, >> {ID:"003", >> Value:""},]) ; >> >> When I pass this var arrR into a .NET webservice and delegate it to an >> ArrayList, the items in the array list will have one of the arrays only >> containing 1 item (instead of 2). >> >> Adding to my problem is the fact that the arrays inside the array list >> when >> read in .NET should have th
RE: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService
Why not use XMLListCollection and send the xml to .net as a string? There is little value in building an ArrayCollection of generic obects. You can sort/filter an XMLListCollection. XML is more verbose than some other methods, but if bandwidth is truly an issue, then you should be looking at a binary protocol. Tracy Spratt, Lariat Services, development services available _ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Angelo Anolin Sent: Friday, July 03, 2009 2:09 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Hi Sam, Basically this is the process which I am using. .NET Retrieve records from Oracle DB and store the same into a dataset. Return the dataset as XML string via the command DataSet.GetXML. Flex In the event handler of my webservice method call, I parse the string into XML, then ArrayCollection via the following codes: private var _xmlData:XML; [Bindable] private var arrDP:ArrayCollection = new ArrayCollection; _xmlData = XML(event.result); var oTemp:Object; var xl:XMLList = _xmlData.children(); var i:int; for(i = 0; i < xl.length(); i++) { oTemp = {NAME:xl[i].NAME.text(), TEAM:xl[i].TEAM.text(), JERSEY:xl[i].JERSEY.text(), MANAGER:xl[i].MANAGER.text()}; arrDP.addItem(oTemp); } and in my datagrid, I am setting its dataProvider to the arrDP variable. I used Array Collection because I implemented a search and filter functionality which searches and filters the data accordingly for the dataprovider which is then reflected back to the datagrid. Now, when I need to return the ArrayCollection to .NET, I simply pass the same as a parameter to a .NET function which accepts ArrayList as parameter. .NET Once the function receieves the arraycollection (which is then now an array list), I get the arrays inside the arraylist and get the values inside the array. I think by doing things like this, it may not be the best way. You mentioned you'd map the XML to typed objects in .NET. How can I do this? Instead of using arraycollection as dataprovider in my datagrid, can I use another which would be much easier when I pass back to the .NET function? Whats the best way to interact large set of data (datasets) between .NET and Flex? Thanks a lot. _ From: Sam Lai To: flexcoders@yahoogroups.com Sent: Friday, 3 July, 2009 13:52:12 Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Instead of using an array list and trying to emulate the type-less abilities of AS3, I'd try to map the XML to typed objects in .NET. Or does the XML from your Flex app differ too wildly to do this? Are you using the XmlSerializer to deserialize this? Or are you using WCF? Or are you doing it some other way, or manually? I'd provide an example, but I don't know enough details on your situation to give something useful :) 2009/7/3 Angelo Anolin mailto:angelo_anolin%40yahoo.com> yahoo.com>: > > > Hi Sam, > > Care to show some examples? I am parsing the arrayCollection into an > ArrayList on .NET. This is particularly not too appealing since I just > discovered that for example, if one of the objects in the arraycollection > would have an empty string value, the number of items inside the array is > not reflected properly in .NET. > > Like: > > private var arrR:ArrayCollectio n = new ArrayCollection( [{ID:"001" , > Value:"Select" }, > {ID:"002", > Value:"Choose" }, > {ID:"003", > Value:""},]) ; > > When I pass this var arrR into a .NET webservice and delegate it to an > ArrayList, the items in the array list will have one of the arrays only > containing 1 item (instead of 2). > > Adding to my problem is the fact that the arrays inside the array list when > read in .NET should have the object ID and Value be in order but they are > not. This is further true when there are many items in the array > collection. Sometimes, the first item becomes the last one in the array > list, and sometimes the order is not well. > > In any case, I am finding a solution on how I would be able to pass an > ArrayCollection to .NET and be able to parse it properly. > > Thanks. > > _____ _____ __ > From: Sam Lai mailto:samuel.lai%40gmail.com> > > To: flexcod...@yahoogro ups.com <mailto:flexcoders%40yahoogroups.com> > Sent: Thursday, 2 July, 2009 15:46:58 > Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When > Passed to .NET WebService > > How is it being parsed in .NET? You can parse it into a hashta
Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService
I just wrote up a simple C# web service that accepts an ArrayList: [WebMethod] public bool ArrayListTest(System.Collections.ArrayList a) { ... } Then in Flex I wrote this, http://localhost:63868/Service1.asmx?WSDL"; id="ws"> When sendWebServiceCall is triggered, it calls the C# web service and passes the ArrayCollection to it. In the web service, the ArrayCollection is received as an array list of XmlNodes. Each XmlNode contains a node for each field, even if it is an empty string. http://tempuri.org/";>808 http://tempuri.org/";>bob http://tempuri.org/";> http://tempuri.org/";>fred Is this anything like what you're getting? The edge case you described in another email about an empty string causing problems doesn't seem to cause problems. Also see inline. 2009/7/3 Angelo Anolin : > I think by doing things like this, it may not be the best way. > > You mentioned you'd map the XML to typed objects in .NET. How can I do > this? As you're using a dataset, this isn't really an option. A dataset as opposed to a collection of typed objects are two ways of handling data from data sources; it is arguable which way is better. The problem in your case, is that the XML generated as a result of passing an ArrayCollection to a web service method cannot be passed into the dataset's readXml method. (Even if it could by inferring a schema, it would be different to your database's schema.) The only way I know of to do seamless transfer of data without having to parse XML is to use WebORB. Otherwise you will have to parse the XML produced on both sides to re-create the dataset/object. > Instead of using arraycollection as dataprovider in my datagrid, can I use > another which would be much easier when I pass back to the .NET function? I wonder if it is possible to bind your datagrid directly to the e4x XML? That way you can pass the entire XML doc back to .NET via the web service, and hence you can re-create the dataset using dataset.readXML. > ____ > From: Sam Lai > To: flexcoders@yahoogroups.com > Sent: Friday, 3 July, 2009 13:52:12 > Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When > Passed to .NET WebService > > Instead of using an array list and trying to emulate the type-less > abilities of AS3, I'd try to map the XML to typed objects in .NET. Or > does the XML from your Flex app differ too wildly to do this? > > Are you using the XmlSerializer to deserialize this? Or are you using > WCF? Or are you doing it some other way, or manually? > > I'd provide an example, but I don't know enough details on your > situation to give something useful :) > > 2009/7/3 Angelo Anolin : >> >> >> Hi Sam, >> >> Care to show some examples? I am parsing the arrayCollection into an >> ArrayList on .NET. This is particularly not too appealing since I just >> discovered that for example, if one of the objects in the arraycollection >> would have an empty string value, the number of items inside the array is >> not reflected properly in .NET. >> >> Like: >> >> private var arrR:ArrayCollectio n = new ArrayCollection( [{ID:"001" , >> Value:"Select" }, >> {ID:"002", >> Value:"Choose" }, >> {ID:"003", >> Value:""},]) ; >> >> When I pass this var arrR into a .NET webservice and delegate it to an >> ArrayList, the items in the array list will have one of the arrays only >> containing 1 item (instead of 2). >> >> Adding to my problem is the fact that the arrays inside the array list >> when >> read in .NET should have the object ID and Value be in order but they are >> not. This is further true when there are many items in the array >> collection. Sometimes, the first item becomes the last one in the array >> list, and sometimes the order is not well. >> >> In any case, I am finding a solution on how I would be able to pass an >> ArrayCollection to .NET and be able to parse it properly. >> >> Thanks. >> >> _ _ __ >> From: Sam Lai >> To: flexcod...@yahoogro ups.com >> Sent: Thursday, 2 July, 2009 15:46:58 >> Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order >> When >> Passed to .NET WebService >> >> How is it being parsed in .NET? You can parse it into a hashtable, or >> better yet, use a pre-defined object. >> >> Not sure why the order is different, but it is probably fragile to >> rely on
Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService
Hi Sam, Basically this is the process which I am using. .NET Retrieve records from Oracle DB and store the same into a dataset. Return the dataset as XML string via the command DataSet.GetXML. Flex In the event handler of my webservice method call, I parse the string into XML, then ArrayCollection via the following codes: private var _xmlData:XML; [Bindable] private var arrDP:ArrayCollection = new ArrayCollection; _xmlData = XML(event.result); var oTemp:Object; var xl:XMLList = _xmlData.children(); var i:int; for(i = 0; i < xl.length(); i++) { oTemp = {NAME:xl[i].NAME.text(), TEAM:xl[i].TEAM.text(), JERSEY:xl[i].JERSEY.text(), MANAGER:xl[i].MANAGER.text()}; arrDP.addItem(oTemp); } and in my datagrid, I am setting its dataProvider to the arrDP variable. I used Array Collection because I implemented a search and filter functionality which searches and filters the data accordingly for the dataprovider which is then reflected back to the datagrid. Now, when I need to return the ArrayCollection to .NET, I simply pass the same as a parameter to a .NET function which accepts ArrayList as parameter. .NET Once the function receieves the arraycollection (which is then now an array list), I get the arrays inside the arraylist and get the values inside the array. I think by doing things like this, it may not be the best way. You mentioned you'd map the XML to typed objects in .NET. How can I do this? Instead of using arraycollection as dataprovider in my datagrid, can I use another which would be much easier when I pass back to the .NET function? Whats the best way to interact large set of data (datasets) between .NET and Flex? Thanks a lot. From: Sam Lai To: flexcoders@yahoogroups.com Sent: Friday, 3 July, 2009 13:52:12 Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Instead of using an array list and trying to emulate the type-less abilities of AS3, I'd try to map the XML to typed objects in .NET. Or does the XML from your Flex app differ too wildly to do this? Are you using the XmlSerializer to deserialize this? Or are you using WCF? Or are you doing it some other way, or manually? I'd provide an example, but I don't know enough details on your situation to give something useful :) 2009/7/3 Angelo Anolin : > > > Hi Sam, > > Care to show some examples? I am parsing the arrayCollection into an > ArrayList on .NET. This is particularly not too appealing since I just > discovered that for example, if one of the objects in the arraycollection > would have an empty string value, the number of items inside the array is > not reflected properly in .NET. > > Like: > > private var arrR:ArrayCollectio n = new ArrayCollection( [{ID:"001" , > Value:"Select" }, > {ID:"002", > Value:"Choose" }, > {ID:"003", > Value:""},]) ; > > When I pass this var arrR into a .NET webservice and delegate it to an > ArrayList, the items in the array list will have one of the arrays only > containing 1 item (instead of 2). > > Adding to my problem is the fact that the arrays inside the array list when > read in .NET should have the object ID and Value be in order but they are > not. This is further true when there are many items in the array > collection. Sometimes, the first item becomes the last one in the array > list, and sometimes the order is not well. > > In any case, I am finding a solution on how I would be able to pass an > ArrayCollection to .NET and be able to parse it properly. > > Thanks. > > ________ _________ _________ __ > From: Sam Lai > To: flexcod...@yahoogro ups.com > Sent: Thursday, 2 July, 2009 15:46:58 > Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When > Passed to .NET WebService > > How is it being parsed in .NET? You can parse it into a hashtable, or > better yet, use a pre-defined object. > > Not sure why the order is different, but it is probably fragile to > rely on the order in this case. > > 2009/7/2 Angelo Anolin : >> >> >> Hi FlexCoders, >> >> I have an array collection which I am populating as follows: >> >> var oTemp:Object; >> var xl:XMLList = _xmlData.children( ); >> var i:int; >> for(i = 0; i < xl.length(); i++) >> { >> oTemp = {ID_TAG:xl[i] .ID.text( ), CAT_TAG:xl[i] .CAT.text( ), >> DET_TAG:xl[i] .DET.text( ), REP_DATE_TAG: xl[i].REP_ DATE.text( ), >> IND_TAG:xl[i] .IND.text( )}; >> arrDP.addItem( oTemp); >> } >> Now, when I pass back this Array Collection back into a web service, the >>
Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService
Instead of using an array list and trying to emulate the type-less abilities of AS3, I'd try to map the XML to typed objects in .NET. Or does the XML from your Flex app differ too wildly to do this? Are you using the XmlSerializer to deserialize this? Or are you using WCF? Or are you doing it some other way, or manually? I'd provide an example, but I don't know enough details on your situation to give something useful :) 2009/7/3 Angelo Anolin : > > > Hi Sam, > > Care to show some examples? I am parsing the arrayCollection into an > ArrayList on .NET. This is particularly not too appealing since I just > discovered that for example, if one of the objects in the arraycollection > would have an empty string value, the number of items inside the array is > not reflected properly in .NET. > > Like: > > private var arrR:ArrayCollection = new ArrayCollection([{ID:"001", > Value:"Select"}, > {ID:"002", > Value:"Choose"}, > {ID:"003", > Value:""},]); > > When I pass this var arrR into a .NET webservice and delegate it to an > ArrayList, the items in the array list will have one of the arrays only > containing 1 item (instead of 2). > > Adding to my problem is the fact that the arrays inside the array list when > read in .NET should have the object ID and Value be in order but they are > not. This is further true when there are many items in the array > collection. Sometimes, the first item becomes the last one in the array > list, and sometimes the order is not well. > > In any case, I am finding a solution on how I would be able to pass an > ArrayCollection to .NET and be able to parse it properly. > > Thanks. > > ________________ > From: Sam Lai > To: flexcoders@yahoogroups.com > Sent: Thursday, 2 July, 2009 15:46:58 > Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When > Passed to .NET WebService > > How is it being parsed in .NET? You can parse it into a hashtable, or > better yet, use a pre-defined object. > > Not sure why the order is different, but it is probably fragile to > rely on the order in this case. > > 2009/7/2 Angelo Anolin : >> >> >> Hi FlexCoders, >> >> I have an array collection which I am populating as follows: >> >> var oTemp:Object; >> var xl:XMLList = _xmlData.children( ); >> var i:int; >> for(i = 0; i < xl.length(); i++) >> { >> oTemp = {ID_TAG:xl[i] .ID.text( ), CAT_TAG:xl[i] .CAT.text( ), >> DET_TAG:xl[i] .DET.text( ), REP_DATE_TAG: xl[i].REP_ DATE.text( ), >> IND_TAG:xl[i] .IND.text( )}; >> arrDP.addItem( oTemp); >> } >> Now, when I pass back this Array Collection back into a web service, the >> fields are not in order as I have added them into the array collection. >> >> I am expecting that in my Web Service, when I parse this arraycollection >> (via arraylist), I would be getting the same order of columns as I have >> added them, i.e. the first array in the array list would have element 0 to >> be the value I placed in the ID. >> >> Since the arraylist does not have the field tag (represented by ID_TAG, >> DET_TAG, CAT_TAG, etc..), it becomes a trial and error (hit and miss) on >> my >> part since I can only reference the value via the index on the array. >> >> Now, how would I be able to include the tags inside array collection such >> that when I read them as an array list in my .NET webservice, I know which >> element I am referring to in a particular index. >> >> Thanks. >> >> Regards, >> Angelo >> >> >> > > > >
Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService
Hi Sam, Care to show some examples? I am parsing the arrayCollection into an ArrayList on .NET. This is particularly not too appealing since I just discovered that for example, if one of the objects in the arraycollection would have an empty string value, the number of items inside the array is not reflected properly in .NET. Like: private var arrR:ArrayCollection = new ArrayCollection([{ID:"001", Value:"Select"}, {ID:"002", Value:"Choose"}, {ID:"003", Value:""},]); When I pass this var arrR into a .NET webservice and delegate it to an ArrayList, the items in the array list will have one of the arrays only containing 1 item (instead of 2). Adding to my problem is the fact that the arrays inside the array list when read in .NET should have the object ID and Value be in order but they are not. This is further true when there are many items in the array collection. Sometimes, the first item becomes the last one in the array list, and sometimes the order is not well. In any case, I am finding a solution on how I would be able to pass an ArrayCollection to .NET and be able to parse it properly. Thanks. From: Sam Lai To: flexcoders@yahoogroups.com Sent: Thursday, 2 July, 2009 15:46:58 Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService How is it being parsed in .NET? You can parse it into a hashtable, or better yet, use a pre-defined object. Not sure why the order is different, but it is probably fragile to rely on the order in this case. 2009/7/2 Angelo Anolin : > > > Hi FlexCoders, > > I have an array collection which I am populating as follows: > > var oTemp:Object; > var xl:XMLList = _xmlData.children( ); > var i:int; > for(i = 0; i < xl.length(); i++) > { > oTemp = {ID_TAG:xl[i] .ID.text( ), CAT_TAG:xl[i] .CAT.text( ), > DET_TAG:xl[i] .DET.text( ), REP_DATE_TAG: xl[i].REP_ DATE.text( ), > IND_TAG:xl[i] .IND.text( )}; > arrDP.addItem( oTemp); > } > Now, when I pass back this Array Collection back into a web service, the > fields are not in order as I have added them into the array collection. > > I am expecting that in my Web Service, when I parse this arraycollection > (via arraylist), I would be getting the same order of columns as I have > added them, i.e. the first array in the array list would have element 0 to > be the value I placed in the ID. > > Since the arraylist does not have the field tag (represented by ID_TAG, > DET_TAG, CAT_TAG, etc..), it becomes a trial and error (hit and miss) on my > part since I can only reference the value via the index on the array. > > Now, how would I be able to include the tags inside array collection such > that when I read them as an array list in my .NET webservice, I know which > element I am referring to in a particular index. > > Thanks. > > Regards, > Angelo > > >
Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService
How is it being parsed in .NET? You can parse it into a hashtable, or better yet, use a pre-defined object. Not sure why the order is different, but it is probably fragile to rely on the order in this case. 2009/7/2 Angelo Anolin : > > > Hi FlexCoders, > > I have an array collection which I am populating as follows: > > var oTemp:Object; > var xl:XMLList = _xmlData.children(); > var i:int; > for(i = 0; i < xl.length(); i++) > { > oTemp = {ID_TAG:xl[i].ID.text(), CAT_TAG:xl[i].CAT.text(), > DET_TAG:xl[i].DET.text(), REP_DATE_TAG:xl[i].REP_DATE.text(), > IND_TAG:xl[i].IND.text()}; > arrDP.addItem(oTemp); > } > Now, when I pass back this Array Collection back into a web service, the > fields are not in order as I have added them into the array collection. > > I am expecting that in my Web Service, when I parse this arraycollection > (via arraylist), I would be getting the same order of columns as I have > added them, i.e. the first array in the array list would have element 0 to > be the value I placed in the ID. > > Since the arraylist does not have the field tag (represented by ID_TAG, > DET_TAG, CAT_TAG, etc..), it becomes a trial and error (hit and miss) on my > part since I can only reference the value via the index on the array. > > Now, how would I be able to include the tags inside array collection such > that when I read them as an array list in my .NET webservice, I know which > element I am referring to in a particular index. > > Thanks. > > Regards, > Angelo > > >
[flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService
Hi FlexCoders, I have an array collection which I am populating as follows: var oTemp:Object; var xl:XMLList = _xmlData.children(); var i:int; for(i = 0; i < xl.length(); i++) { oTemp = {ID_TAG:xl[i].ID.text(), CAT_TAG:xl[i].CAT.text(), DET_TAG:xl[i].DET.text(), REP_DATE_TAG:xl[i].REP_DATE.text(), IND_TAG:xl[i].IND.text()}; arrDP.addItem(oTemp); } Now, when I pass back this Array Collection back into a web service, the fields are not in order as I have added them into the array collection. I am expecting that in my Web Service, when I parse this arraycollection (via arraylist), I would be getting the same order of columns as I have added them, i.e. the first array in the array list would have element 0 to be the value I placed in the ID. Since the arraylist does not have the field tag (represented by ID_TAG, DET_TAG, CAT_TAG, etc..), it becomes a trial and error (hit and miss) on my part since I can only reference the value via the index on the array. Now, how would I be able to include the tags inside array collection such that when I read them as an array list in my .NET webservice, I know which element I am referring to in a particular index. Thanks. Regards, Angelo