XMLListCollection vs. ArrayCollection

Hello,
I was recently speaking with a colleague about the merits of
working with native XML across client and server tiers of a Flex
app vs. marshaling/unmarshaling XML to/from objects, and he
mentioned that in his experience, the performance of working with
ArrayCollections was much better than that of XMLListCollections,
up to an order of magnitude or better. So I Googled a bit, and I
found this:
http://blog.fastlanesw.com/?p=14
This is a blog post that references some apparent comments
from someone from Adobe on this very issue, and suggests that E4X
may be a liability, at least from a memory standpoint. Between my
colleague's experiences and recommendations, and this blog post, it
raises the following questions:
1) Is there indeed a significant performance and/or memory
penalty for using E4X/XMLListCollections?
2) If the answer to 1) is yes, is this a design flaw, and
will be fixed at some point, or no?
3) If the answer to 1) is yes, then when would ever using E4X
be advisable? It seems the using E4X in general would be a
liability.
My particular reason I am asking is a fairly standard one. I
am trying to determine if it is wiser to orient client and server
architecture code to standard AS3 class objects, and marshal in and
out of xml when communicating between client and the server (i.e.
XML over the wire but objects, but after crossing the wire, marshal
out of XML to AS3 objects into ArrayCollections, and data bind the
UI to objects); OR, orient the client and server to native xml, and
use native XML not only across the wire, but E4X to marshal into
XMLListCollections and data bind to these objects instead. Native
XML structures and E4X on the client seem very attractive, as it
eliminates a lot of the trouble in having to code
marshaling/unmarshaling. But if it comes with a major
performance/memory price, then it is probably a bad architectural
idea. Customers don't much care about ease of development, they
want a stable, performant app.
Can anyone speak definitively to this?
Thanks!
Brad

Yes I meant query.  By' bringing it in' I mean it's bringing in an actionscript object.
So any query including using an arrayList (like the following) would be converted to an XMLlist?
I thought arrayLists are separate from XMLLists.
  <fx:Declarations>
    <fx:Model id="categoryModel" source="data/categories.xml"/>
    <s:ArrayList id="categoryCollection" source="{categoryModel.category}"/>
  </fx:Declarations>
  <mx:DataGrid id="categoryGrid" dataProvider="{categoryCollection}"/>
In any case I'm still not sure why you would need to use an XMLCollection since you can use an ArrayCollection.

Similar Messages

  • XMLListCollection vs. ArrayCollection perofrmance

    Hello,
    I was recently speaking with a colleague about the merits of
    working with native XML across client and server tiers of a Flex
    app vs. marshaling/unmarshaling XML to/from objects, and he
    mentioned that in his experience, the performance of working with
    ArrayCollections was much better than that of XMLListCollections,
    up to an order of magnitude or better. I wanted to try to verify
    this, and if true, to inquire as to the reason for this -- is it an
    initial design issue, and will be fixed, or is this something that
    is known and expected to be the situation going forward?
    The reason I am asking, of course, is to try to determine if
    it is wiser to orient client and server code to standard objects,
    and marshal in and out of xml, or orient the client and server to
    native xml. Native XML structures and E4X on the client seem
    attractive, if it eliminates marshaling, but if it comes with a
    major performance price, then I'm inclined not to go that route.
    Thanks for your help.
    Brad

    Tracy,
    Thanks for the response. I'm not speaking of anything
    theoretical here. I'm asking about a fixed performance difference
    between using XMLListCollections and ArrayCollections. If there is
    a significant cost to using XMLListCollections vs. using
    ArrayCollections, then for the purposes of designing a
    client-server architecture on marshaling in/out of data obects vs.
    XML, the XML/E4X is ill-advised. I don't know how it could be
    viewed otherwise. And if there are memory issues whenever E4X is
    used in data-binding as well, I'm not quite sure what the
    production purpose of E4X would be. I mean, it might be great for
    prototyping, but why would you base a system architecture on
    something that has a potential order of magnitude (referring to my
    colleague's claim here) performance hit, and a significant memory
    penalty?
    Hence my desire to confirm this. E4X is dynamite for
    convenience. But clients don't much care about developer
    convenience, they want a solid, stable, performant application. And
    if this is true, it pretty much takes any use of E4X off the table,
    which would be a shame, because I'd much prefer to use E4X. Is
    there any way to contact Adobe with questions?
    Thanks,
    Brad

  • Converting string(which is an xml from the java side) to xml in flex

    Hi,
       I have an xml from the java side which i send as string over amf. I need to convert this to xmllist or xml and bind it to a tree. Could some one help me in doing this. My label field needs to be displayName
    this is my xml that comes as string to the flex side
    <Menu>
      <MenuItem>
        <id>1</id>
        <displayName>Add</displayName>
        <menuList>
          <MenuItem>
            <id>3</id>
            <displayName>Form1</displayName>
            <menuList/>
          </MenuItem>
          <MenuItem>
            <id>4</id>
            <displayName>Form2</displayName>
            <menuList/>
          </MenuItem>
        </menuList>
      </MenuItem>
      <MenuItem>
        <id>2</id>
        <displayName>Delete</displayName>
        <menuList>
          <MenuItem>
            <id>5</id>
            <displayName>Form1</displayName>
            <menuList/>
          </MenuItem>
          <MenuItem>
            <id>6</id>
            <displayName>Form2</displayName>
            <menuList/>
          </MenuItem>
        </menuList>
      </MenuItem>
    </Menu>

    Well, for Binding you will probably need to further convert to XMLListCollection or ArrayCollection.
    Not sure.
    However, that is the way to convert String to XML.

  • Dynamic binding expression to get data from array

    I am retrieveing from an object to label my button as
    follows:
    quote:
    <mx:Button label = "{wordlist.word.LABEL[0][index]}"
    I now want the binding expression to be dynamic, meaning that
    LABEL has to be a variable. How would I do this?
    quote:
    <mx:Button label =
    "{wordlist.word.????[LABEL]????[0][index]}"

    "lunacafu" <[email protected]> wrote in
    message
    news:gqte13$1g4$[email protected]..
    >I am retrieveing from an object to label my button as
    follows:
    >
    >
    quote:
    <mx:Button label = "{wordlist.word.LABEL[0][index]}"
    >
    > I now want the binding expression to be dynamic, meaning
    that LABEL has to
    > be
    > a variable. How would I do this?
    >
    >
    quote:
    <mx:Button label =
    "{wordlist.word.????[LABEL]????[0][index]}"
    First, if wordlist.word.LABEL is an XMLListCollection or
    ArrayCollection,
    you need to use getItemAt instead of bracket notation. Once
    you get to that
    point, you need to cast it to whatever data type the object
    at 0 is.
    HTH;
    Amy

  • Why is it different using ArrayCollection and XMLListCollection?

    As shown in the screenshot below. The first one has ArrayCollection as dataProvider. The second one has XMLListCollection as dataProvider.
    I would like the result for XMLListCollection but now I only have ArrayCollection as input. How can I deal with it? Thanks!
    <?xml version="1.0" encoding="utf-8"?> 
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" >
              <mx:Script> 
                        <![CDATA[ 
                                  import mx.collections.ArrayCollection; 
                                  [Bindable] 
                                  private var dp:ArrayCollection = new ArrayCollection([ 
                                            {name: "00:00:00", v1: "2"},
                                            {name: "00:15:00", v1: "3"},
                                            {name: "00:30:00", v1: "4"},
                                            {name: "00:45:00", v1: "3"},
                                            {name: "01:00:00", v1: "5"},
                                            {name: "01:15:00"},
                                            {name: "01:30:00"},
                                            {name: "01:45:00"},
                                            {name: "02:00:00"}
                        ]]>
              </mx:Script> 
              <mx:XMLListCollection id="dp2">
                        <mx:source>
                                  <mx:XMLList>
                                            <hour name="00:00:00" v1="2"/>
                                            <hour name="00:15:00" v1="3"/>
                                            <hour name="00:30:00" v1="4"/>
                                            <hour name="00:45:00" v1="3"/>
                                            <hour name="01:00:00" v1="5"/>
                                            <hour name="01:15:00" />
                                            <hour name="01:30:00" />
                                            <hour name="01:45:00" />
                                            <hour name="02:00:00" />
                                  </mx:XMLList>
                        </mx:source>
              </mx:XMLListCollection>
              <mx:LineChart id="lineChart" height="100%" width="100%" dataProvider="{dp}" showDataTips="true"> 
                        <mx:horizontalAxis> 
                                  <mx:CategoryAxis categoryField="name"/> 
                        </mx:horizontalAxis> 
                        <mx:series> 
                                  <mx:LineSeries yField="v1" form="curve" displayName="v1"/>
                        </mx:series> 
              </mx:LineChart> 
              <mx:Legend dataProvider="{lineChart}" direction="horizontal"/>
              <mx:LineChart id="lineChart2" height="100%" width="100%" dataProvider="{dp2}" showDataTips="true"> 
                        <mx:horizontalAxis> 
                                  <mx:CategoryAxis categoryField="@name"/> 
                        </mx:horizontalAxis> 
                        <mx:series> 
                                  <mx:LineSeries yField="@v1" form="curve" displayName="v1"/>
                        </mx:series> 
              </mx:LineChart> 
              <mx:Legend dataProvider="{lineChart2}" direction="horizontal"/>
    </mx:Application>

    Define a default value to v1 for each of your objects in the ArrayCollection, or even better, use a strongly typed model class. In XML this would resolve to null (or maybe an empty string?), but an object will throw a "property not found" error, which may have unexpected results (as seen above).

  • Arraycollection to xmllistcollection

    Is there an easy way to convert an ArrayCollection to an
    XMLListCollection? I have found plenty of references to convert the
    reverse, but none that go into an XMLListCollection or XMLList.
    I am receiving a query from a database via a RemoteObject and
    putting it directly into an ArrayCollection. Some of this data
    needs to be displayed in a Tree and I've found XMListCollection
    works better as a data provider. I wrote a method to go through the
    array and create nodes then add them to the XML, but it seems there
    would be a way to do this automatically instead. Thanks!

    You cannot cast unless the cariable you are casting contains
    an object of the type you are casting to.
    ArrayCollection will never contain an XMLListcollection, so
    forget casting.
    If the CFC IS returning xml, then set the resultFormat="e4x",
    then in the handler, do:
    var xmlResult:XML = XML(event.result);
    trace(xmlResult.toXMLString())
    Tracy

  • Arraycollection into XMLlistcollection

    Hi all,
    I am trying to create my xmllistcollection since days, and getting soo unsuccessful each time...
    I have a flat simple arraycollection like :
    id_order
    client_name
    orders_name
    1
    client_name 1
    order_name 1
    2
    client_name 2
    order_name 2
    3
    client_name 3
    order_name 3
    4
    client_name 1
    order_name 4
    Objective: I want to display the above data in a tree, group by client_name.
    Please can you help me to create that xmllistcollection ?
    Thanks
    ps: what i have done so far:
    [Bindable]
    private var myXMLlist:XML = <clients></clients>;
    [Bindable]
    private var XMListcol:XMLListCollection;
    private function createXML():void
         XMListcol = new XMLListCollection;
         var clientNamePrev:String;
         for (var i:int = 0; i < allOrders_array.length; i++)
              var ordName:String = allOrders_array.getItemAt(i).orders_name;
              var idOrders:String = allOrders_array.getItemAt(i).id_orders;
              var clientName:String = allOrders_array.getItemAt(i).client_name;
              var clientNameTag:XML = <clientname>{clientName}</clientname>;
              //Alert.show("idOrders:"+ idOrders+ "order name:"+ ordName);
              var new0rderTag:XML = <ordername id={idOrders}>{ordName}</ordername>;
              if(clientNamePrev == clientName)
                   Alert.show("clientNameTag: "+ clientNameTag);
                   clientNameTag.appendChild(new0rderTag);     
              else
                   //Alert.show("ord Prev: "+clientNamePrev + " orderName: "+ clientName);     
                   myXMLlist = myXMLlist.appendChild(clientNameTag);
              clientNamePrev= clientName;
         XMListcol = new XMLListCollection(myXMLlist.children());
         Alert.show("listxml: "+ myXMLlist.descendants());

    Hi
    Do you know how could i access the attribute 'id' from the tag '<ordername id =xx>'?
    please find below the solution to my difficulties:
    private function createXML():void
         var myXMLlist:XML = <clients></clients>;
         var clientNamePrev:String = "";
         var clientNameTag:XML;
         //Alert.show("arraylength : " +allOrders_array.getItemAt(20).client_name );
         for (var i:int = 0; i < allOrders_array.length; i++)
              var ordName:String = allOrders_array.getItemAt(i).orders_name;
              var idOrders:String = allOrders_array.getItemAt(i).id_orders;
              var clientName:String = allOrders_array.getItemAt(i).client_name;
              var new0rderTag:XML = <ordername id={idOrders} label={ordName}/>;                        
              if (clientNamePrev == "")
                   clientNameTag = <clientname label={clientName}></clientname>;
                   clientNameTag.appendChild(new0rderTag);                        
              else if(clientNamePrev == clientName)
                   clientNameTag.appendChild(new0rderTag);
                   //Alert.show("clientNameTag: "+ clientNameTag);
              else if(clientNamePrev != clientName)
                   //Alert.show("ord Prev: "+clientNamePrev + " orderName: "+ clientName);    
                   myXMLlist = myXMLlist.appendChild(clientNameTag);
                   clientNameTag = <clientname label={clientName}></clientname>;
                   clientNameTag.appendChild(new0rderTag);                        
              else
                   Alert.show("Please contact Administrator @ [email protected]", "Alert");
              if (i == (allOrders_array.length - 1))
                   myXMLlist = myXMLlist.appendChild(clientNameTag);
              clientNamePrev= clientName;
         XMListcol = new XMLListCollection(myXMLlist.children());
         //Alert.show("listxml:" + XMListcol);
    Thank you

  • HTTP Service XML to ArrayCollection

    Hi,
    How do I convert the results from a remote XML List file
    called using the HTTPService method into an arrayCollection for
    sorting filtering etc. ??? (I assume it is the arrayCollection
    please feel free to suggest a better method)
    I have this working by calling the XML as a model that
    compiles at runtime, it'd be nice to have this work dynamically
    Thanks
    Rich

    If your data is in XML format, you may want to read it in as
    XML, and use an XMLList (or XMLListCollection wrapping the XMLList)
    to do the management of it.
    In terms of how to read it in at runtime (I assume that's
    what you're asking?) try something along these lines:
    internal var myXMLList:XMLList;
    internal function loadData() : void
    var XML_URL:String = "myData.xml";
    var myXMLURL:URLRequest = new URLRequest(XML_URL);
    var myLoader:URLLoader = new URLLoader();
    myLoader.addEventListener("complete", dataLoaded);
    try
    myLoader.load(myXMLURL);
    } catch(error:Error)
    trace("Failed to load Data");
    internal function dataLoaded(evtObj:Event) : void
    var myLoader:URLLoader = URLLoader(evtObj.target);
    var myXML:XML = XML(myLoader.data);
    myXMLList = myXML.ListedElement;
    }

  • Update DataGrid over ArrayCollection

    Hey,
    I have got a problem with the updating capabiliy of the
    ArrayCollection.
    I fill the array like this.
    quote:
    [Bindable]
    private var content:ArrayCollection = new ArrayCollection();
    private function contentRPCResult(event:ResultEvent):void {
    content = event.result.allEntries.entry;
    The data I like to fill the ArrayCollection with, is
    information I got from a mysql database over PHP. It needs to be
    reloaded from time to time, because the content changes quiet
    frequently. So I used a "Refresh" button. While clicking on it the
    RPC "contentRPC.send();" gets sent again. The command works fine,
    because the first time the database content loads into the app.
    If I click on the refresh button, nothing happens. I thought,
    if the content of an ArrayCollection changes, the content of its
    dataprovider changes as well?! I used an XMLListCOllection in
    another app, there it works. If I send the HTTPRquest again, the
    content changes if there were any changes since the last load.
    I even tried removeAll() or refresh() to empty the Array and
    fill it again with the new data. It doesn't work. Only the first
    loaded content is displayed in the data provider. If i reload the
    whole app, the content shows the actuall content (which is the
    first loaded content, indeed!).
    So my question is: I fill an ArrayCollection with
    "contentRPC.send();" (HTTPRequest) once. The dataprovider shows the
    content. When I user "contentRPC.send()" again and the new content
    is different to the old one, how could I refill the ArrayCollection
    with the new content (it should automatically change the content of
    the dataprovider)?
    Hopefully you understand my problem. I am actually German, so
    it was hard for me to explain, what I really intend to do!
    Thanks for any help.
    greets lindner

    Hey Vygo,
    thank you for your answer. Unfurtunatly it is not a cache
    problem. I tried the unique thing, which sounds very meaningful.
    But the ArrayCollection still gets not refreshed, or reloaded. When
    I use the PHP Script on its own, it always shows the current
    content, using no cache at all. So I know the right content gets
    passed to the flex app, but the app does not use it!
    Any other suggestions, maybe there is a cache problem in
    flex?
    I just took a look in the older app where I used an
    XMLListCollection to fill the dataprovider.
    There the command to gill the XMLListCollection was
    "HTTPRequest_ID.
    lastResult.XML_node". Now I fill the ArrayCollection only
    with "content = event.
    result.allEntries.entry;". I can not use lastResult at this
    point. Might this be a problem? I an't believe there is no way to
    fill an ArrayCollection at runtime more than one time?!
    greetings lindner

  • Help with xmlListCollection and getItemAt method!

    All,
      I have a simple application in which I have a data grid, http sevice and xmllistcollection. I get the xml data and populate the xmllistcollection. Objective is to traverse the xmlcollection to get the first row, parse and set the column headers dynamically.
    the first row in the xmllistcollection are the column headers. I am trying to get the values using the getItemAt(0) method, which does return a object but not sure how to traverse the object to draw the column headers for the data grid dynamically? below is the sample example
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
      <![CDATA[
       import mx.collections.ArrayCollection;
       import mx.rpc.events.ResultEvent;
       import mx.rpc.events.FaultEvent;
       import mx.controls.Alert;
       import mx.controls.dataGridClasses.DataGridColumn;
              public function fetch():void
          xmlRPC.send();        
          var i:int = 0;     
          var a:XMLList = new XMLList(xdata.getItemAt(0).toString() as XMLList); 
         Alert.show(a.text() + "a");
         for each(var xml:XML in a)
           Alert.show("I am inside" + i);
           var attributes:XMLList = xml.attributes();
           var o:Object = new Object();
           for each (var attribute:XML in attributes)
            Alert.show("I am  way inside" + i);
            var nodeName:String = attribute.name().toString();
            var value:*;
            Alert.show(attribute.toString());
            value = attribute.toString();
               i = i+1;   
      ]]>
    </mx:Script>
        <mx:HTTPService result="handleXMLnew(event);" fault="handleFault(event);" id="xmlRPC" resultFormat="e4x"
        url="http://abc/Xcelsius/swat/RCD.xsql" useProxy="false">
    </mx:HTTPService>
    <mx:XMLListCollection id="xdata" source="{xmlRPC.lastResult.ROW}"/>
    <mx:DataGrid dataProvider="{xdata}" x="24" y="110" id="adg1" width="694" height="168"/>
    <mx:Button x="653" y="44" label="Go" click="fetch();"/>
    </mx:Application>

    try this, to  parse and set the column headers dynamically.
    http://flexpearls.blogspot.com/2008/02/generating-dg-columns-for-xml-data.html
    Hope this will work.

  • ArrayCollection vs. XML e4x

    I have an application where most of my data comes from web
    services returning arrayColletctions of Objects. I use the
    arrayCollections as my data provider for various data grids. I have
    built a text field for filtering my data grids by using the
    filterFunction of the arrayCollection. Everything works great!
    Now I am populating another datagrid with XML directly thus I
    am using e4x for all my access to the data. I am having a lot of
    difficulty with the most basic functions in my datagrid sorting
    columns and don't have a clue how to implement the filterFunction.
    On my datagrid using e4x I implemented a labelFunction for each
    column to extract the data as well as a sortCompareFunction. For
    some reason my sortCompare function is not working. Some of the
    data is sorted but not all of it.
    Does this sound familiar to anyone? Any ideas where to look?
    Below is some sample code to see if that helps . . .
    Thanks for any help you can offer.

    You have several problems with your code here, and it doesn't
    have anything to do with the data being an ArrayCollection or an
    XMLListCollection.
    One of the problems is the fact that you have "On Behalf Of"
    with an extra space between Behalf and Of. Your sortCompareFunction
    could never even compare the right values. I probably don't have to
    say too much more on comparing strings that contain spaces, right?
    <mx:DataGridColumn headerText="On Behalf Of"
    dataField="text.(@columnnumber == '2')" width="80"
    labelFunction="getNotesName"
    sortCompareFunction="compareNonDateValues">
    The second issue is, you cannot use an E4X expression for the
    dataField (it won't evaluate to anything), this is why you're using
    a labelFunction on that column.
    The third is when you're trying to compare the strings within
    compareNonDateValues(), you're comparing the whole object (you used
    data1 and data2), when you should be comparing the strings data1Str
    and data2Str :
    return ( data1Str.toLowerCase() < data2Str.toLowerCase() )
    ? -1 : ( data1Str.toLowerCase() > data2Str.toLowerCase() ) ? 1 :
    0;
    Not to want to rag on you here, but I hope that you're the
    only one who has to look at that nested ternary. It's just very
    hard to read and even harder to catch a simple mistake.
    The following works for me, see if it does for you. I've
    abbreviated the XML elements, but you get the idea.
    TS

  • HTTPService::ArrayCollection::DataGrid

    the code:
    <mx:Script <[[CDATA[
    public var file:ArrayCollection = new ArrayCollection();
    public function resultHandler(event:ResultEvent){
    //arraycollection assignemnt
    public function faultHandler(event:FaultEvent){
    //alert
    ]]>
    <mx:HTTPService id="http" url="random.XML"
    result="resultHandler(event)"
    fault="faultHandler(event)"/>
    <mx:ArraryCollection id="ac"
    dataProvider="{http.lastResult.etc.etc.etc}" />
    <mx:DataGrid id="dg" dataProvider="{ac}" />
    For whatever reason this isn't working. the dataprovider
    specifically is causing me issues. thoughts?

    1) The default resultFormat = object. This causes Flex to
    convert your xml into a tree structure of dynamic objects. This is
    rarely desirable.
    2) set resultFormat="e4x" to preserve your xml
    3) Option A: loop over the XMLList and build an
    ArrayCollection of strongly typed value objects.
    3) Option B: The simplest way to proceed is to use
    XMLListCollection. Declare it in instance scope:
    [Bindable]private var _xlcResult:XMLListCollection;
    Bind the datagrid to that var:
    <mx:DataGrid id="dg" dataProvider="{_xlcResult}" />
    Set the dataGridColumns dataField to the xml node @attributes
    or child nodes depending on the xml
    Assign the XMLListCollection in the resultHandler:
    var xmlResult:XML = XML(event.result);
    trace(xmlResult.toXMLString()); //to be sure of your
    structure
    _xlcResult = new XMLListCollection(xmlResult.etc.etc);
    Tracy

  • Duplicates when binding ArrayCollection to List

    Hi,
    I'm working on a flex application.
    There is a DataManger object that loads some XML data and store it in an ArrayCollection by doing something like that (code is simplified) :
    private var _xmlLocations:XMLListCollection;
    private var _countryList:ArrayCollection;
    _xmlLocations = new XMLListCollection(data..location);
    _countryList.addAll(_xmlLocations.list)
    Then the DataManager send back the ArrayCollection to a component with a list using the Source setter.
    <mx:ArrayCollection id="arrayData" />
    <mx:List id="listMenu" dataProvider="{arrayData}">...</mx:List>
    public function set Source(data:ArrayCollection):void{
         arrayData.source = data.source;
    When I look at my ArrayCollection in the debugger, it first look like this :
    But after the binding to the List, the ArrayCollection arrayData has every entry duplicated...
    I'm probably doing something wrong... but what?
    Thanks for any lighting or advices

    I cannot confirm your issue, I've created simple test MXML application  to validate it
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    layout="absolute"
                   creationComplete="onCreationComplete()">   
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                protected var initArr : Array = new Array(1, 2, 3);           
                protected var initCollection : ArrayCollection = new ArrayCollection(initArr);
                [Bindable]
                protected var dataCollection : ArrayCollection = new ArrayCollection();
                public function set source(data:ArrayCollection):void {
                    dataCollection.source = data.source;
                private function onCreationComplete() : void {
                    source = initCollection;  
            ]]>
        </mx:Script>
        <mx:List dataProvider="{dataCollection}"/>
    </mx:Application>

  • Cannot read an ArrayCollection variable assigned by LCDS

    Hi,<br /><br />      I am new to flex and lcds.  pls. help me to understand.  All I am trying to do here is take the hibernate sample from lcds sample application and replace the grid control with a tree control.  In order achieve this, I was trying to convert the ArrayCollection into an XMLListCollection object through an actionscript in a function called convertToXML.  How ever, I'm having the difficulty in this conversion.  When i tried to debug the action script, the arraycollection, which is suppose to be with full values, seems to empty.  But, still it shows up the records in the grid.  pls. help to understand, why, I can't manipulate the ArrayCollection?<br /><br />  For your reference, Following is the modifed modified lines of the original lcds sample code.<br /><br /><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:local="*" layout="absolute" <br />     width="100%" height="100%"<br />    pageTitle="Hibernate"<br />     creationComplete="convertToXML()"><br /><br />     <!--<br />          <mx:Tree id="list" width="100%" height="100%" dataProvider="{projectData}" labelField="@name"/><br />     --><br />          <mx:DataGrid id="list" width="100%" height="100%" dataProvider="{contacts}"<br />               doubleClick="openTab(list.selectedItem as Contact)" doubleClickEnabled="true"><br />               <mx:columns><br />                    <mx:DataGridColumn dataField="firstName" headerText="First Name"/><br />               </mx:columns><br />          </mx:DataGrid><br /><br />               [Bindable]<br />            private var projects:XML =<br />              <list><br />                <projects name="Projects" code="0"><br />                </projects><br />              </list>;<br /><br />            [Bindable]<br />            private var projectData:XMLListCollection = <br />                new XMLListCollection(projects.projects);<br />               <br />               private function convertToXML():void {<br />                    ds.fill(contacts, 'all', []);<br />                    for each (var proj:Contact in contacts) {<br />                         addProject(proj.lastName + ", " + proj.firstName);     <br />                    }                    <br />               }<br />               <br />               private function addProject(projName:String):void {<br />                var newNode:XML = <project/>;<br />                newNode.@name = projName;<br />                var proj:XMLList = projects.projects.(@name == "Projects");<br />                if( proj.length() > 0 ) {<br />                    proj[0].appendChild(newNode);<br />                }<br />            }<br /><br />               private function treeLabel(item:Object):String {<br />                var node:XML = XML(item);<br />                if( node.localName() == "department" )<br />                    return node.@title;<br />                else<br />                    return node.@name;<br />            }

    If I understand correctly you must read a BLOB from a foregin database but have no privleges to create any supporting objects. This sounds painful.
    Options to get to the BLOB include (all with problems to solve)
    * through database link
    * extract LOB to OS and re-load into database
    **flat file
    **datapump file
    Some options - I hope someone provides better ideas, but until that happens ...
    Can you create objects on the other side - where the BLOB comes from? If you can, consider writing a (pipelined?) function to read the BLOB, chop it up into smaller pieces, transfeer the pieces over a database link, and reassemble the pieces in the remote database using DBMS_LOB in PL/SQL. Not elegant.
    You should be able to use the scheduler to create a job to use datapump to extract the BLOB and possibly transfer it too but how to access the OS file? You said you have no privileges to create objects, and that would include external tables. Could you find an existing directory object and use the folder already defined (risky; using a different application's infrastructure can be hard to maintain and will break when the underlying directly goes away)?
    Edited by: riedelme on Jun 13, 2011 12:08 PM

  • HTTPService of e4x sending data from an XMLListCollection?

    I'm converting an applicaton to use e4x httpservice calls to get and send variables to a PHP remote service and seems to have run into a few questions I can't find any forums posts or documentation about. Currently the application uses the object model to get data and sends and receives variables
    from the PHP scripts through a bunch of $_POST variables. When pulling stuff into the application it gets stored in an array collection so I can sort it and search it easily using cursors. Here are my questions:
    Getting stuff from an HTTPservice with a type of e4x is easy. works great. I toss it right into an XMLarraycollection and get my sorting. But sending data to the same service setup as a type of 'e4x' I can't figure out. Using the object model I could just send an object of keys and properties so sending a { key : value }, would go to the PHP file as a $_POST['key'] and I could read the value. Since httpservice of e4x enforces the need for a root XML tag, all I seem to get is a $_POST['root'], and none of the real key:value data I need. I'm clearing missing something. So how on the PHP side do I get my values if I have to send this root tag? Or in flex how to I send XMLlists instead of XML.? This has to be possible. I don't want to use a different service just to send.
    Second, and a minor thing. When I do send variables to  and httpservice of e4x from an XML arraycollection, do I just send it in key:value format, or do I need to toString() it? When it gets to the php script after the post would the variable name and value be $_POST['key']=value or $_POST[<key>']=<value>.
    Thanks in advance!  

    hi,
    have you looked at creating a new document with the root tag as parent then inserting the collection, haven't tried this with xmllistcollection but I would think the process is similar to the atraycollection conversion
    var qName:QName = new QName("root");
    var xmlDocument:XMLDocument = new XMLDocument();
    var simpleXMLEncoder:SimpleXMLEncoder = new SimpleXMLEncoder(xmlDocument);
    var xmlNode:XMLNode = simpleXMLEncoder.encodeValue(myArrayCollection.source, qName, xmlDocument);
    trace(xmlDocument.toString());
    David

Maybe you are looking for