ArrayCollection as Data Provider in Tree

Hi,
     Does anybody know how to use ArrayCollection as a data provider in tree control as i have to access the data later from the database. I'm able to use XMLList as the data provider in the tree control but unable to use ArrayCollection as data provider.
Please help me in this.
Thanxs
Gaurav

Actually I was just thinking about something I am currently doing.  I am not sure if a tree control will accept a HierarchicalData object as its dataprovider but what you can do is create an array of associative arrays where one of the keys is called children.  This key called children would then point to another associative array.  It could nest down as far as you want but would look absolutely terrible.  I still think XMLList is the way to go but if you really dont want to do that you can try and work this.  Here is some sample of what a simple HierarchicalData object looks like:
private var masterData:Array = [
             { OrderId: 10248, CustomerId:"WILMK", EmployeeId:5, OrderDate:"1-Feb-2007",
            children:[
                        {ProductId:11, ProductName:"Quesbo Cabrales", UnitPrice:14, Quantity:12, Discount:0, Price:168},
                        {ProductId:42, ProductName:"Singaporean Hokkien Fried Mee", UnitPrice:9.8, Quantity:10, Discount:0, Price:98},
                        {ProductId:42, ProductName:"Mozzarella di Giovanni", UnitPrice:34.8, Quantity:5, Discount:0, Price:174}
             { OrderId: 10249, CustomerId:"TRADH", EmployeeId:6, OrderDate:"3-Feb-2007",
                 children:[
                    {ProductId:51, ProductName:"Manjimup Dried Appels", UnitPrice:42.4, Quantity:40, Discount:0, Price:1696},
                    {ProductId:14, ProductName:"Tofu", UnitPrice:18.6, Quantity:9, Discount:0, Price:167.4}
             { OrderId: 10250, CustomerId:"HANAR", EmployeeId:4, OrderDate:"4-Feb-2007",
                 children:[
                    {ProductId:51, ProductName:"Manjimup Dried Appels", UnitPrice:42.4, Quantity:35, Discount:0.15, Price:1261},
                    {ProductId:41, ProductName:"Jack's Clam Chowder", UnitPrice:7.7, Quantity:10, Discount:0, Price:77},
                    {ProductId:65, ProductName:"Hot pepper Sauce", UnitPrice:16.8, Quantity:10, Discount:0.15, Price:214.2}
I got this example from a tutorial online explaining how to use nested AdvancedDataGrids but hopefully you can see my point on how you could nest the "nodes" in their parents children object.  It has to be called children because the data object is defaulted to look there. If you created this type of Array all you would have to do then is:
var hierData:HierarchicalData = new HierarchicalData(masterData);

Similar Messages

  • How to change the data provider of the tree with the selection of combobox

    This is my XML data in a file named `nodesAndStuff.xml`.
        <?xml version="1.0" encoding="utf-8"?>
        <root>
            <node label="One" />
            <node label="Two" />
            <node label="Three" />
            <node label="Four" />
            <node label="Five" />
            <node label="Six" />
            <node label="Seven" />
            <node label="Eight" />
            <node label="Nine" />
        </root>
    The component using this data source is an `XMLListCollection` which is bound to a spark `ComboBox` and the code for that is:
        <s:Application name="Spark_List_dataProvider_XML_test"
            xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/halo"
            initialize="init();">
        <fx:Script>
            <![CDATA[
                private function init():void {
                    xmlListColl.source = nodes.children();
    private function closeHandler(event:Event):void {
                    myLabel.text = "You selected: " +  ComboBox(event.target).selectedItem.label;                 myData.text = "Data: " +  ComboBox(event.target).selectedItem.data;
            ]]>
        </fx:Script>
        <fx:Declarations>
            <fx:XML id="nodes" source="nodesAndStuff.xml" />
        </fx:Declarations>
        <mx:ComboBox id="cmbList" dataProvider="{ListXLC}" labelField="STOREVALUE"  close="closeHandler(event);"/>
         <s:dataProvider>
            <s:XMLListCollection id="xmlListColl" />
         </s:dataProvider>
    </mx:ComboBox>
    <mx:VBox width="250" color="0x000000">
                <mx:Text  width="200" color="blue" text="Select a type of credit card."/>
                <mx:Label id="myLabel" text="You selected:"/>
                <mx:Label id="myData" text="Data:"/>
            </mx:VBox> 
    <mx:Tree id="myTree" width="50%" height="100%" visible="false" />
    </s:Application>
    now another of my xml for example this is one.xml
    <?xml version="1.0" encoding="utf-8"?>
    <root>
        <node label="Eleven" />
        <node label="Twelve" />
        <node label="Thirteen" />
        <node label="Fourteen" />
        <node label="Fifteen" />
        <node label="Sixteen" />
        <node label="Seventeen" />
        <node label="Eightteen" />
        <node label="Nineteen" />
    </root>
    and another one is two.xml
    <?xml version="1.0" encoding="utf-8"?>
    <root>
        <node label="twety one" />
        <node label="twety two" />
        <node label="twety three" />
        <node label="twety four" />
        <node label="twety five" />
        <node label="twety six" />
        <node label="twety seven" />
        <node label="twety eight" />
        <node label="twety nine" />
    </root>
    Now I have added my tree just below the list and I have saved counting from 10 to 19 in `one.xml`, 20 to 29 in `two.xml` and so on in different XML file. I have no clue how to connect the XML containing counting from 10 to 19 as the single node in tree at the selection of label one in list and make its visiblity true.this all are dependent on combobox as on selection of item in combobox will lead to change the dataprovider of tree at runtime. i.e on selecting value one in combobox one.xml should be the data provider for tree control. Can anyone help me on this

    This is my XML data in a file named `nodesAndStuff.xml`.
        <?xml version="1.0" encoding="utf-8"?>
        <root>
            <node label="One" />
            <node label="Two" />
            <node label="Three" />
            <node label="Four" />
            <node label="Five" />
            <node label="Six" />
            <node label="Seven" />
            <node label="Eight" />
            <node label="Nine" />
        </root>
    The component using this data source is an `XMLListCollection` which is bound to a spark `ComboBox` and the code for that is:
        <s:Application name="Spark_List_dataProvider_XML_test"
            xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/halo"
            initialize="init();">
        <fx:Script>
            <![CDATA[
                private function init():void {
                    xmlListColl.source = nodes.children();
    private function closeHandler(event:Event):void {
                    myLabel.text = "You selected: " +  ComboBox(event.target).selectedItem.label;                 myData.text = "Data: " +  ComboBox(event.target).selectedItem.data;
            ]]>
        </fx:Script>
        <fx:Declarations>
            <fx:XML id="nodes" source="nodesAndStuff.xml" />
        </fx:Declarations>
        <mx:ComboBox id="cmbList" dataProvider="{ListXLC}" labelField="STOREVALUE"  close="closeHandler(event);"/>
         <s:dataProvider>
            <s:XMLListCollection id="xmlListColl" />
         </s:dataProvider>
    </mx:ComboBox>
    <mx:VBox width="250" color="0x000000">
                <mx:Text  width="200" color="blue" text="Select a type of credit card."/>
                <mx:Label id="myLabel" text="You selected:"/>
                <mx:Label id="myData" text="Data:"/>
            </mx:VBox> 
    <mx:Tree id="myTree" width="50%" height="100%" visible="false" />
    </s:Application>
    now another of my xml for example this is one.xml
    <?xml version="1.0" encoding="utf-8"?>
    <root>
        <node label="Eleven" />
        <node label="Twelve" />
        <node label="Thirteen" />
        <node label="Fourteen" />
        <node label="Fifteen" />
        <node label="Sixteen" />
        <node label="Seventeen" />
        <node label="Eightteen" />
        <node label="Nineteen" />
    </root>
    and another one is two.xml
    <?xml version="1.0" encoding="utf-8"?>
    <root>
        <node label="twety one" />
        <node label="twety two" />
        <node label="twety three" />
        <node label="twety four" />
        <node label="twety five" />
        <node label="twety six" />
        <node label="twety seven" />
        <node label="twety eight" />
        <node label="twety nine" />
    </root>
    Now I have added my tree just below the list and I have saved counting from 10 to 19 in `one.xml`, 20 to 29 in `two.xml` and so on in different XML file. I have no clue how to connect the XML containing counting from 10 to 19 as the single node in tree at the selection of label one in list and make its visiblity true.this all are dependent on combobox as on selection of item in combobox will lead to change the dataprovider of tree at runtime. i.e on selecting value one in combobox one.xml should be the data provider for tree control. Can anyone help me on this

  • Populating a Tree data provider dynamically

    Hi,
    I have made an XMLLIstCollection as the data provider of a
    Tree control. I want to add the tree nodes dynamically. Now the
    problem is that I am able to add a node to the collection but not a
    sub-node. Can anybody plz tell me the way to do it?
    Thanks,
    Cheree

    I tried with your code the following mxml program:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    creationComplete="initApp()">
    <mx:Script>
    <![CDATA[
    import mx.collections.XMLListCollection;
    [Bindable]
    public var a:XMLList=new XMLList();
    [Bindable]
    public var xml:XML;
    [Bindable]
    public var coll:XMLListCollection=new XMLListCollection(a);
    public var xmlIn:String = "<node label='new'/>";
    public var xmlNode:XML=new XML(xmlIn);
    public function initApp():void{
    xml= <node label="sdf" isBranch="true"/>;
    coll.addItem(xml);
    xml=<node label="sdf">{xml}</node>;
    coll.addItem(xml);
    xml=<node label="goi">{a}</node>;
    //xml.node[0].subnode[0].appendChild(xmlNode);
    coll.addItemAt(xml,0);
    ]]>
    </mx:Script>
    <mx:Tree id="myTree" dataProvider="{coll}"
    labelField="@label"/>
    </mx:Application>
    If I uncomment the line that you suggested, I get the error :
    TypeError: Error #1010: A term is undefined and has no
    properties.
    at TestFile2/initApp()
    at TestFile2/___Application1_creationComplete()
    at
    flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/set initialized()
    at mx.managers::LayoutManager/::doPhasedInstantiation()
    at Function/
    http://adobe.com/AS3/2006/builtin::apply()
    at mx.core::UIComponent/::callLaterDispatcher2()
    at mx.core::UIComponent/::callLaterDispatcher()

  • Using HTTPService as data provider for mx:ComboBox

    Hello all,
    I'm trying to use an HTTPService as a data provider for an
    mx:ComboBox. Here's how I have my HTTPService configured:
    <mx:HTTPService id="listStates" url="
    http://localhost:3006/state/list"
    useProxy="false" method="GET" />
    I have a Rails backend setup and talking to a database on my
    local machine. I have a list of states in a table in my database,
    and the table has two columns: id and name. When I go to
    localhost:3006/state/list in my browser, I get the following XML:
    <states>
    <state>
    <id type="integer">1</id>
    <name>New Mexico</name>
    </state>
    <state>
    <id type="integer">2</id>
    <name>Arizona</name>
    </state>
    </states>
    I have my mx:ComboBox set up like so:
    <mx:ComboBox width="199" id="state" dataProvider="{
    listStates.lastResult.states.state }" />
    However, when I browse to my .swf file, my state combo box
    shows [object Object] twice in the drop-down list. Anyone have any
    idea why it's not parsing the data correctly? Any suggestions on
    how to make it work?
    Thanks in advance!!! -- BTR

    Alright I worked one out for you. Let me know if you have any
    questions.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute"
    creationComplete="dropDown.send()">
    <mx:Script>
    <![CDATA[
    import mx.rpc.events.ResultEvent;
    import mx.collections.ArrayCollection;
    import mx.controls.Alert;
    public var dropArr:XML;
    public function get_drop_down(e:ResultEvent):void{
    dropArr = e.result as XML;
    state.dataProvider = dropArr.state;
    state.labelField = "name";
    state.data = "id";
    ]]>
    </mx:Script>
    <mx:HTTPService id="dropDown" useProxy="false"
    url="
    http://localhost/dropDown.php"
    resultFormat="e4x"
    result="get_drop_down(event)" />
    <mx:ComboBox width="199" id="state" />
    </mx:Application>

  • How to bind BubbleSeries data provider?

    Hi,
    I have a bubbleChart and multiple bubble series inside it. Initially I set the data provider of each of my series. Later, when I update the array collections (to which my bubble series's data provider was binded), bubble series' data provider is not updated.
    <mx:BubbleChart>
         <mx:BubbleSeries dataprovider={arr[0]}>
         </mx:BubbleSeries>
         <mx:BubbleSeries dataprovider={arr[1]}>
         </mx:BubbleSeries>
         <mx:BubbleSeries dataprovider={arr[2]}>
         </mx:BubbleSeries>
    </mx:BubbleChart>
    In actionscript, arr[0],arr[1] and arr[2] are updated. I want to see updated bubbleseries too, but in vain.
    I have marked arr as bindable.
    Please help..
    Thanks,
    Tanu

    Hi Tanu Jain,
    If you have no problem updating the values there itself.. then you can do one thing...But the way you are trying to update the things is however correct but it will not update the values for BubbleSeries. The reason is why because the each object and its properties in the expenses array collection are not Bindable as since the objects in the expenses array collection are generic objects.
    In order to make the objects bindable you can make use of a seperate class and make all the properties Bindable as needed so that you can acheive things you needed.
    And one more thing here to note is ...when you are assiging the dataProvider the first time in the for loop you are using the below line of code...
    bubbleSeries.dataProvider = expenses.getItemAt(i);
    But in the click handler you are reassigning the dataProvider as expenses = expenses1; by doing so you are assigning/adding new items to your expenses ArrayCollection but the binding you assigned to the bubbleSeries dataProvider are different items so there is no possibility of updating the values to the BubbleSeries by this approach so you should update the values there itself by making use of external Bindable class so that Bubble Series gets updated correctly.
    Actually I got this sorted out yesterday itself but you said as you are having some 200 - 300 series it is taking more time delay to get updated by reassigning the dataProvider by looping through the series as I suggested in my previous post. By updating the values there itself say if you have some 300 - 400 rows in your expenses ArrayCollection then you need to loop through all the rows(300 - 400 times)  and update all the properties within that Object.
    Any way try this example below which I am explaining above...hope this is less expensive when compared to reassigning the dataProvider again..
    <!-- Bindable class BubbleSeriesVO -->
    package
    [Bindable]
    public class BubbleSeriesVO
            public var Month:String;
            public var Profit:Number;
            public var Expenses:Number;
            public var amt:Number;
      public function BubbleSeriesVO()
    <!-- Application Source Code -->
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="955" minHeight="600" creationComplete="init()">
        <mx:Script>
            <![CDATA[
                import mx.charts.series.BubbleSeries;
                import mx.collections.ArrayCollection;
                /* [Bindable]
                public var expenses:ArrayCollection = new ArrayCollection([
                    {Month:"Jan", Profit:2000, Expenses:1500,amt:200},
                    {Month:"Feb", Profit:1000, Expenses:200,amt:340},
                    {Month:"Mar", Profit:1500, Expenses:500,amt:500}
                [Bindable]public var expenses:ArrayCollection;
                [Bindable]public var expenses1:ArrayCollection;
                /* [Bindable]
                public var expenses1:ArrayCollection = new ArrayCollection([
                    {Month:"Jan", Profit:2500, Expenses:1500,amt:1000},
                    {Month:"Feb", Profit:1500, Expenses:200,amt:2000},
                    {Month:"Mar", Profit:2000, Expenses:500,amt:1500}
                private function createExpensesCollection():void
                 //Creating expenses ArrayCollection
                 expenses = new ArrayCollection();
                 var bubbleVO:BubbleSeriesVO = new BubbleSeriesVO();
                 bubbleVO.Month = "Jan";
                 bubbleVO.Profit = 2000;
                 bubbleVO.Expenses = 1500;
                 bubbleVO.amt = 200;
                 expenses.addItem(bubbleVO);
                 bubbleVO = new BubbleSeriesVO();
                 bubbleVO.Month = "Feb";
                 bubbleVO.Profit = 1000;
                 bubbleVO.Expenses = 200;
                 bubbleVO.amt = 340;
                 expenses.addItem(bubbleVO);
                 bubbleVO = new BubbleSeriesVO();
                 bubbleVO.Month = "Mar";
                 bubbleVO.Profit = 1500;
                 bubbleVO.Expenses = 500;
                 bubbleVO.amt = 500;
                 expenses.addItem(bubbleVO);
                 //Creating expenses1 ArrayCollection
                 expenses1 = new ArrayCollection();
                 bubbleVO = new BubbleSeriesVO();
                 bubbleVO.Month = "Jan";
                 bubbleVO.Profit = 2500;
                 bubbleVO.Expenses = 1500;
                 bubbleVO.amt = 1000;
                 expenses1.addItem(bubbleVO);
                 bubbleVO = new BubbleSeriesVO();
                 bubbleVO.Month = "Feb";
                 bubbleVO.Profit = 1500;
                 bubbleVO.Expenses = 200;
                 bubbleVO.amt = 2000;
                 expenses1.addItem(bubbleVO);
                 bubbleVO = new BubbleSeriesVO();
                 bubbleVO.Month = "Mar";
                 bubbleVO.Profit = 2000;
                 bubbleVO.Expenses = 500;
                 bubbleVO.amt = 1500;
                 expenses1.addItem(bubbleVO);
                private function init():void
                 createExpensesCollection();
                    var bubbleSeriesColl:Array = new Array();
                    for(var i:int = 0; i < expenses.length; i++)
                        var bubbleSeries:BubbleSeries = new BubbleSeries();
                        bubbleSeries.xField = "Profit";
                        bubbleSeries.yField = "Expenses";
                        bubbleSeries.radiusField = "amt";
                        bubbleSeries.dataProvider = expenses.getItemAt(i);
                        bubbleSeriesColl.push(bubbleSeries);               
                    myChart.series = bubbleSeriesColl;               
                private function clickHandler():void
                    //expenses = expenses1;
                    for(var i:int = 0; i < expenses1.length; i++)
                     if(i >= expenses.length)
                      break;
                     (expenses.getItemAt(i) as BubbleSeriesVO).Month = (expenses1.getItemAt(i) as BubbleSeriesVO).Month;
                     (expenses.getItemAt(i) as BubbleSeriesVO).Profit = (expenses1.getItemAt(i) as BubbleSeriesVO).Profit;
                     (expenses.getItemAt(i) as BubbleSeriesVO).Expenses = (expenses1.getItemAt(i) as BubbleSeriesVO).Expenses;
                     (expenses.getItemAt(i) as BubbleSeriesVO).amt = (expenses1.getItemAt(i) as BubbleSeriesVO).amt;
                    expenses.refresh();
                    //updateBuubleSeries();
                private function updateBuubleSeries():void
                  for(var i:int = 0; i < myChart.series.length; i++)
                        myChart.series[i].dataProvider = expenses.getItemAt(i);
            ]]>
        </mx:Script>
        <mx:BubbleChart id="myChart" showDataTips="true">          
        </mx:BubbleChart>
        <mx:Button label="change Data" click="clickHandler()" />
    </mx:Application>
    Thanks,
    Bhasker

  • I have a problem with a chart refreshing after its bound data provider changes.

    I have a problem with a chart refreshing after its bound data
    provider changes. After the subsetHighLowData.refresh() is called I
    would expect the chart to redraw, but it still looks the same. I
    even inspected the debugger to see if the slice had taken place and
    it had.
    Any ideas coding friends?

    "nikos101" <[email protected]> wrote in
    message
    news:gib6aa$prr$[email protected]..
    >I have a problem with a chart refreshing after its bound
    data provider
    >changes.
    > After the subsetHighLowData.refresh() is called I would
    expect the chart
    > to
    > redraw, but it still looks the same. I even inspected
    the debugger to see
    > if
    > the slice had taken place and it had.
    >
    > Any ideas coding friends?
    >
    > subsetHighLowData.source =
    >
    highLowData.source.slice(slider.values[0],slider.values[1]);
    Just use the ArrayCollection's removeItemAt, and it should
    handle the event
    dispatching for you.
    HTH;
    Amy

  • Need help coneverting data provider for inline fx:Component renderer for a datagrid

    I want to use an existing inline item renderer and point the hard coded data provider to an arraycollection, which comes from a database.
    At firt glance this looks easy, just change
    <fx:Declarations>
      <fx:Component id="inlineEditor">
       <mx:ComboBox >
        <mx:dataProvider>
         <fx:String></fx:String>
         <fx:String>AIG</fx:String>
         <fx:String>BHN</fx:String>
         <fx:String>FH</fx:String>
         <fx:String>LM</fx:String>
         <fx:String>SD</fx:String>
        </mx:dataProvider>
       </mx:ComboBox>
      </fx:Component>
    </fx:Declarations>
    TO
    <fx:Declarations>
      <fx:Component id="inlineEditor">
       <mx:ComboBox
        dataProvider="{outerDocument.wripAttachTypeAc}"
        labelField="WRIP_ATTACHED_FILE_TYPE_DESC">
       </mx:ComboBox>
      </fx:Component>
    </fx:Declarations>
    BUT that does not work the data grid produces the object.object value as theres no association to the labelField . Can anyone see what I am doing wrong. The datagrid entry is
    <mx:DataGridColumn dataField="Permit File"
              width="150"
              editorDataField="selectedItem"
              itemEditor="{inlineEditor}"/>

    Thanks Harui, but it doesn't help. If the border is set it will help, but the very big problem is the empty rows that appear at the end of the datagrid... I can't find a way of measuring correctly the height of the itemRenderers!
    I'll update this thread if I manage to do it.

  • Newbie attempting to use Data Provider

    Hello everyone, I just downloaded Flex and am eager to learn
    but I'm having some difficulties finding any debugging tools to
    help me troubleshoot the code below. I basically grabbed the data
    provider example and tried to rework it for something I need but
    the cursor gets set to busy and the data never loads.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="400" height="300" creationComplete="qSrv.send()">
    <mx:Script>
    <![CDATA[
    import mx.rpc.events.InvokeEvent;
    import mx.managers.CursorManager;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.events.FaultEvent;
    import mx.controls.Alert;
    import mx.collections.ArrayCollection;
    [Bindable]
    private var questionsCol:ArrayCollection;
    // Gets called when HTTPService is invoked to
    // request the XML.
    private function qSrvInvokeHandler(event:InvokeEvent):void
    // Display the busy cursor
    CursorManager.setBusyCursor();
    // Gets called when the XML is successfully loaded.
    private function qSrvResultHandler(event:ResultEvent):void
    // Save a reference to the list of questions
    questionsCol = event.result.MBTI.question;
    // Hide the busy cursor
    CursorManager.removeBusyCursor();
    private function qSrvFaultHandler(event:FaultEvent):void
    // There was an error in loading the XML
    Alert.show (event.fault.message);
    // Hide the busy cursor
    CursorManager.removeBusyCursor();
    ]]>
    </mx:Script>
    <mx:HTTPService id="qSrv" url="data/questions.xml"
    invoke="qSrvInvokeHandler(event);"
    result="qSrvResultHandler(event);"
    fault="qSrvFaultHandler(event);" />
    </mx:Canvas>
    and the xml located in the data folder:
    <?xml version="1.0" encoding="UTF-8"?>
    <MBTI>
    <question>
    <description>
    You are almost never late for your appointments
    </description>
    </question>
    </MBTI>

    Okay here is a different way of doing it. It doesn't seem to
    render properly if I have a canvas component and try to load the
    data, only if it's within the application directly. Below is the
    code I currently have, why does the label of the QuestionHBox
    always come up blank?
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    xmlns:components="*" layout="absolute"
    creationComplete="qSrv.send()">
    <mx:Script>
    <![CDATA[
    import mx.rpc.events.InvokeEvent;
    import mx.managers.CursorManager;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.events.FaultEvent;
    import mx.controls.Alert;
    import mx.collections.ArrayCollection;
    [Bindable]
    private var questionsCol:ArrayCollection;
    // Gets called when HTTPService is invoked to
    // request the XML.
    private function qSrvInvokeHandler(event:InvokeEvent):void
    // Display the busy cursor
    CursorManager.setBusyCursor();
    // Gets called when the XML is successfully loaded.
    private function qSrvResultHandler(event:ResultEvent):void
    // Save a reference to the list of questions
    questionsCol = event.result.MBTI.question;
    // Hide the busy cursor
    CursorManager.removeBusyCursor();
    private function qSrvFaultHandler(event:FaultEvent):void
    // There was an error in loading the XML
    Alert.show (event.fault.message);
    // Hide the busy cursor
    CursorManager.removeBusyCursor();
    ]]>
    </mx:Script>
    <mx:HTTPService id="qSrv" url="data/questions.xml"
    invoke="qSrvInvokeHandler(event);"
    result="qSrvResultHandler(event);"
    fault="qSrvFaultHandler(event);" />
    <mx:Model id="artwork" source="data/questions.xml"/>
    <mx:Panel title="Employee Factor Personality Assessment"
    height="95%" width="95%"
    paddingTop="10" paddingLeft="10" paddingRight="10"
    paddingBottom="10">
    <mx:Text width="100%" color="blue"
    text="Welcome Kim Garland"/>
    <mx:HBox borderStyle="solid" width="100%"
    paddingTop="5" paddingLeft="5" paddingRight="5"
    paddingBottom="5">
    <mx:Button id="searchButton" label="Take Test"
    click="myViewStack.selectedChild=search;"/>
    <mx:Button id="cInfoButton" label="View Results"
    click="myViewStack.selectedChild=custInfo;"/>
    </mx:HBox>
    <!-- Define the ViewStack and the three child containers
    and have it
    resize up to the size of the container for the buttons.
    -->
    <mx:ViewStack id="myViewStack" borderStyle="solid"
    width="100%" height="80%">
    <!-- <components:TestQuestionsPart1 id="search"
    backgroundColor="#FFFFCC" label="Search" width="100%"
    height="100%">
    <mx:Label text="Test Part 1" color="#000000"/>
    </components:TestQuestionsPart1> -->
    <mx:Canvas id="search" backgroundColor="#CCFFFF"
    label="Customer Info" width="100%" height="100%">
    <mx:Label text="Test" color="#000000"/>
    <mx:TileList dataProvider="{questionsCol}"
    itemRenderer="QuestionHBox" />
    <!--<mx:Repeater dataProvider="questionsCol">
    <mx:Label text="name" />
    </mx:Repeater> -->
    </mx:Canvas>
    <mx:Canvas id="custInfo" backgroundColor="#CCFFFF"
    label="Customer Info" width="100%" height="100%">
    <mx:Label text="Test Results" color="#000000"/>
    </mx:Canvas>
    </mx:ViewStack>
    </mx:Panel>
    </mx:Application>
    QuestionHBox:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:HBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="100%" height="20" scroll="false">
    <mx:Label text="{data.name}" width="700" fontSize="12"
    textAlign="left"/>
    <mx:RadioButtonGroup id="radiogroup1"/>
    <mx:RadioButton label="Yes" groupName="radiogroup1"
    height="100%"/>
    <mx:RadioButton label="No" groupName="radiogroup1"
    height="100%"/>
    </mx:HBox>
    questions.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <MBTI>
    <question>
    <name>You are almost never late for your
    appointments</name>
    </question>
    <question>
    <name>You are almost never late for your
    appointments</name>
    </question>
    </MBTI>

  • ComboBox XML Data Provider

    Hello all,
    I'm having trouble creating an XML data provider to use for a
    ComboBox. Below is what I've done:
    XML data I get from Rails server:
    <states>
    <state name="Arizona" id="1" />
    </states>
    CDATA:
    import mx.rpc.events.ResultEvent;
    import mx.collections.ArrayCollection;
    [Bindable] private var stateData:ArrayCollection;
    private function getStates(event:ResultEvent):void {
    stateData = (event.result as XML).states.state;
    state.dataProvider = stateData;
    state.labelField = "name";
    state.data = "id";
    <mx:ComboBox id="state" />
    This compiles, but when I run it, I don't get anything in the
    ComboBox. I know I'm getting data from the server, because I can
    set the data provider for the ComboBox to be event.result and I see
    all the resulting XML in the ComboBox.
    Please help!!! What am I doing wrong here?!
    Thanks in advance! -- BTR

    Hey Vygo,
    Thanks for the suggestion. I'll try it out and let you know
    how it goes. However, I was worried about the attributes so I tried
    it using regular elements as well, but to no avail. Anyway, I'll
    get back to you once I have a chance to try out your suggestion.
    Thanks again! -- BTR

  • Binding Text input value to chart data provider

    Hello, I am trying to develop a flex mobile application that generates the Chart.
    Is there any way to set the text input value as a chart data provider?????
    and if so, can you give me example?????

    Perhaps a stupid question but when you change your
    arraycollection do you do arraycollectioname.refresh()? If not,
    that should be your problem, without the refresh method your visual
    object will not update but your arraycollection will.

  • Dropdown and data provider. I want to add an item to my dropdown

    Hi,
    here my problem. I've a downdrop. It is binded to a data provider. It works fine, all the db rows are displayed.
    Now I want to add an item to my downdrop, programmatically. This because, I need to put a new selection named "ALL" into the dropdown.
    This item should be the first in the dropdown list selections.
    I cant' work with an option array, because it is already binded to a data provider, so how can I add an item to my dropdown programmatically?
    Thank you

    No problem... you're helping me!!
    Well, about the data provider I just find the following code, but nothing about the "option" method. If you need I can provide you also the session bean code.
      private void _init() throws Exception {
            pers_categorieDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet)getValue("#{SessionBean1.pers_categorieRowSet}"));
            private DropDown dropDownPersCat = new DropDown();
        public DropDown getDropDownPersCat() {
            return dropDownPersCat;
        public void setDropDownPersCat(DropDown dd) {
            this.dropDownPersCat = dd;
        private CachedRowSetDataProvider pers_categorieDataProvider = new CachedRowSetDataProvider();
        public CachedRowSetDataProvider getPers_categorieDataProvider() {
            return pers_categorieDataProvider;
        public void setPers_categorieDataProvider(CachedRowSetDataProvider crsdp) {
            this.pers_categorieDataProvider = crsdp;
        private LongConverter dropDownPersCatConverter = new LongConverter();
        public LongConverter getDropDownPersCatConverter() {
            return dropDownPersCatConverter;
        public void setDropDownPersCatConverter(LongConverter lc) {
            this.dropDownPersCatConverter = lc;
          public Indirizzario() {
          public void init() {
            // Perform initializations inherited from our superclass
            super.init();
            // Perform application initialization that must complete
            // *before* managed components are initialized
            // TODO - add your own initialiation code here
            // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
            // Initialize automatically managed components
            // *Note* - this logic should NOT be modified
            try {
                _init();
            } catch (Exception e) {
                log("Indirizzario Initialization Failure", e);
                throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
            // </editor-fold>
            // Perform application initialization that must complete
            // *after* managed components are initialized
            // TODO - add your own initialization code here
         * <p>Callback method that is called after the component tree has been
         * restored, but before any event processing takes place.  This method
         * will <strong>only</strong> be called on a postback request that
         * is processing a form submit.  Customize this method to allocate
         * resources that will be required in your event handlers.</p>
        public void preprocess() {
         * <p>Callback method that is called just before rendering takes place.
         * This method will <strong>only</strong> be called for the page that
         * will actually be rendered (and not, for example, on a page that
         * handled a postback and then navigated to a different page).  Customize
         * this method to allocate resources that will be required for rendering
         * this page.</p>
        public void prerender() {
         * <p>Callback method that is called after rendering is completed for
         * this request, if <code>init()</code> was called (regardless of whether
         * or not this was the page that was actually rendered).  Customize this
         * method to release resources acquired in the <code>init()</code>,
         * <code>preprocess()</code>, or <code>prerender()</code> methods (or
         * acquired during execution of an event handler).</p>
        public void destroy() {
            pers_categorieDataProvider.close();
         * <p>Return a reference to the scoped data bean.</p>
        protected SessionBean1 getSessionBean1() {
            return (SessionBean1)getBean("SessionBean1");
         * <p>Return a reference to the scoped data bean.</p>
        protected RequestBean1 getRequestBean1() {
            return (RequestBean1)getBean("RequestBean1");
         * <p>Return a reference to the scoped data bean.</p>
        protected ApplicationBean1 getApplicationBean1() {
            return (ApplicationBean1)getBean("ApplicationBean1");
    }

  • Modifiable two dimensional data provider

    I've been using this tutorial blog of winston prakash to buid a data provider for my project:
    http://blogs.sun.com/winston/entry/displaying_two_dimensional_data
    I have it working perfectly but now I want to extend it with functionality to modify the contents of the data provider (only modify no append, insert or delete).
    So I looked at the source code of data providers that had this functionality (like the ObjectListDataProvider) but I didn't manage to get it to work.
    What I did was change the isReadOnly function to always return false and implement setValue functions.
    but the setValue function is never called when I post the form and I can't find a way to get the content of the post such that I can update the dataprovider manually.
    so can someone please help me?

    The one thing you'll have to watch out for when using Replace Array Subset is you can't replace an element that isn't there. So when you get to the end of your initialized array and still need to add more to it, you'll need to use the Insert into array to add some more space.
    I've modified the example a bit to show one way to this. Doing this is still much more efficient than inserting on every iteration, since the memory allocation only happens when needed.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
    Attachments:
    AddToArrayMod2.vi ‏46 KB

  • How can I use more than one Data Provider in my web Apps

    I am trying to use two different data provider in my web apps to run two different queries from the same table ,the data provider A is working correctly but when I attempt to run data provider B ,It display an error page ,here is the error message : Exception Details :javax.servlet.ServletEx ception
    java.lang.RuntimeException: java.sql.SQLException : Cannot connect .Both dataSourceName and url properties are null.

    Hi,
    You can use more than one data provider in your application. However if you have defined a dataprovider for a particular table already, and wish to bind a component, select the component and use its context menu to Bind to Data...

  • Error while generating Data provider

    We are facing a weird issue while using Design Studio 1.2. Locally the tool works fine but when we use it from BI-Launchpad or through BI Enterprise it gives intermittent error "Error while generating Data Provider"
    Same setup works fine in our Validation Environment.
    We have tried running repair for Design Studio, redeploy the war files, creating new view but issue still exist.
    We have BI 4.0 SP7 installed on Windows 2008 R2 system.
    4 CMS running in cluster, Design Studio 1.2 is installed on 3 Nodes out of 4.
    For now we are using 1 tomcat to access the system to narrow down the issue.
    Experts please help us to resolve this issue.
    Attach is the error message we are receiving

    I am not clear what your data source is, but I recommend checking the PAM https://websmp102.sap-ag.de/~sapidb/011000358700001013822013E because there are some limitations with Design Studio and BI4.0

  • Query View name not saved in "Analysis Grid Properties" under Data Provider

    Hi BW World;)
    We are on BI 7.0
    I have created a BI workbook which contains a query view.
    However when we go into design mode and then "analysis grid properties" for this query view then "change data provider" it does not show the query view name but the query name. (we have saved the workbook)
    Is this the normal scenario?
    Surely should show the "query view name " and not the "query name" as confuses what data provider is being used?
    Is this a bug?
    Best
    Stevo.... Points of course... Thanks in advance.;)
    Edited by: bw4eva999 on Sep 10, 2009 4:40 PM     spelling

    Hi,
    You have created a workbook on top of a Query View which is again depends on a Query.Now the base for Query View is a Query.So the underlying Data Provider for a workbook is a Query.
    Hence when you go to Properties of grid->Change Data Provider,it shows the Query and the InfoCube,but not the Query View.
    So this is not a bug and this how its been designed.
    If you click for the Information of that workbook,it will show the Query and Info Provider,but not the query View.
    Though it looks like wierd,it is not a bug.
    Rgds,
    Murali

Maybe you are looking for