Arraycollection to database

I have an arraycollection that is populated from a
webservice. Users can edit all fields and possible every row in teh
database will need to be modified. I'm trying to find the best way
to get this data back to coldfusion to modify several database rows
at once. Should I loop through the rows on the Flex side and make
several webservice calls to update the database one row at a time?
Or is there a way to pass the arraycollection back to coldfusion as
an object and look through it on the server side. Any help
(including code samples or tutorials) would be greatly appreciated.
Eric

David,
Can't speak for epsnowden, but my main question is how to
prepare this update on the Flex side. Once I figure out a good way
to send an array or a long xml string to the CF server, I'm sure I
can handle it on the ColdFusion side.
Thanks for the offer, though.
So to repeat, does anyone know an elegant way to send updates
to a Flex datagrid back to ColdFusion? For extra credit, I'd prefer
to only update rows that were changed.
Thanks,
Steve

Similar Messages

  • How can i sort a single AdvancedDataGridColumn in a AdvancedDataGrid?

    Hello,
    I am using a ADG, which populates the returned data(arraycollection) from database. I'm generating a counter on java side for each returned record and showing that counter in ADGcolumn. I just want to sort that particular column.
    When i debug the application, i'm getting the counter count properly but when its showing in ADG, sorting is missing. when i clicks on coloum header, then only its showing in ascending order, i need to show up in ascending order without clicking on column header.
    Can anyone help me in this issue??

    Hi Johnny,
    Thanks for your helpful code, its really working for me.
    but i have an issue, once i apply the sort, i'm getting number '1' and down arrow symbol on ADGcolumnheader.
    i'm using a itemrenderer to get rid of '1' but i need to make invisible the down arrow symbol too.
    sortExpertMode property is working for other columns but not for the column which i'm applying sort.
    Here is the code which disabling the number on columnheader:
    package
    import mx.controls.advancedDataGridClasses.AdvancedDataGridSortItemRenderer; 
    import mx.core.UITextField; 
    public class ADGSortItemRenderer extends AdvancedDataGridSortItemRenderer{
    public function ADGSortItemRenderer(){
    //TODO: implement function
    override protected function childrenCreated():void{ 
    super.childrenCreated(); 
    //Get reference to sort number text field
    var sortOrderTextField:UITextField = this.getChildAt(0) as UITextField; 
    if(sortOrderTextField != null){ 
    //Hide sort number text field
    sortOrderTextField.includeInLayout =
    false;sortOrderTextField.visible =
    false;}
    here is the image:
    is there any way to disable both the number(1) & down arrow??
    Thanks,
    Shravan P.

  • ArrayCollection to Java ArrayList to database

    Hi Every bod
    My MXML program sends an array collection to java method
    successfully. But, how I can read in java each attribute of each
    object of the java array list in order to store them?
    Thanks
    Best regards
    Dr. Khaled

    Each object in the ArrayList will be converted into an
    flex.messaging.io.amf.ASObject in Java. An ASObject is basically a
    java.util.Map so you can use the get method.
    In ActionScript: { firstname:"George", lastname:"Washington"
    becomes in Java:
    obj.get("firstname");
    obj.get("lastname");

  • How I can transfer data from the database into a variable (or array)?

    I made my application according to the example (http://corlan.org/2009/06/12/working-in-flash-builder-4-with-flex-and-php/). Everything works fine. I changed one function to query the database - add the two parameters and get the value of the table in String format. A test operation shows that all is ok. If I want to display this value in the text area, I simply drag and drop service to this element in the design mode
    (<s:TextArea x="153" y="435" id="nameText" text="{getDataMeanResult.lastResult[0].name}"  width="296" height="89"  />).
    It also works fine, just a warning and encouraged to use ArrayCollection.getItemAt().
    Now I want to send the value to a variable or array, but in both cases I get an error: TypeError: Error #1010: A term is undefined and has no properties..
    How can I pass a value from the database into a variable? Thank you.
    public var nameTemp:String;
    getDataMeanResult.token = authors.getDataMean(arrayOfNumber[0], dir_id);
    nameTemp = getDataMeanResult.lastResult[0].name;
    public var nameArray:Array = new Array();
    for (var i:uint=o; i<3; i++){
    getDataMeanResult.token = authors.getDataMean(arrayOfNumber[i], dir_id);
    nameArray[i] = getDataMeanResult.lastResult[0].name;
    And how i can use syntax highlighting in this forum?

    Astraport2012 wrote:
    I have to go back to the discussion. The above example works fine when i want to get a single value of the database. But i need to pass an array and get an array, because i want to get at once all the values for all pictures tooltips. I rewrote the proposed Matt PHP-script and it works. However, i can not display the resulting array.
    yep, it won't work for Arrays, you'll have to do something slightly more intelligent for them.
    easiest way would be to get your PHP to generate XML, then read that into something like an ArrayList on your HTTPService result event (depends what you're doing with it).
    for example, you could have the PHP generate XML such as:
    <pictures>
         <location>test1.png</location>
         <location>test2.png</location>
         <location>test3.png</location>
         <location>test4.png</location>
         <location>test5.png</location>
         <location>test6.png</location>
    </pictures>
    then you'll read that in as the ResultEvent, and perform something like this on it
    private var tempAC:ArrayList = new ArrayList
    protected function getStuff_resultHandler(event:ResultEvent):void
        for each(var item:Object in event.result.pictures)
           var temp:String = (item.@location).toString();
           tempAC.addItem(temp);
    in my example on cookies
    http://www.mattlefevre.com/viewExample.php?tut=flash4PHP&proj=Using%20Cookies
    you'll see an example of how to format an XML structure containing multiple values:
    if($_COOKIE["firstName"])
            print "<stored>true</stored>";
            print "<userInfo>
                    <firstName>".$_COOKIE["firstName"]."</firstName>
                    <lastName>".$_COOKIE["lastName"]."</lastName>
                    <userAge>".$_COOKIE["userAge"]."</userAge>
                    <gender>".$_COOKIE["gender"]."</gender>
                   </userInfo>";
        else
            print "<stored>false</stored>";
    which i handle like so
    if(event.result.stored == true)
                        entryPanel.title = "Welcome back " + event.result.userInfo.firstName + " " + event.result.userInfo.lastName;
                        firstName.text = event.result.userInfo.firstName;
                        lastName.text = event.result.userInfo.lastName;
                        userAge.value = event.result.userInfo.userAge;
                        userGender.selectedIndex = event.result.userInfo.gender;
    depends on what type of Array you're after
    from the sounds of it (with the mention of picture tooltips) you're trying to create a gallery with an image, and a tooltip.
    so i'd probably adopt something like
    <picture>
         <location>example1.png</location>
         <tooltip>tooltip for picture #1</tooltip>
    </picture>
    <picture>
         <location>example2.png</location>
         <tooltip>tooltip for picture #2</tooltip>
    </picture>
    <picture>
         <location>example3.png</location>
         <tooltip>tooltip for picture #3</tooltip>
    </picture>
    etc...
    or
    <picture location="example1.png" tooltip="tooltip for picture #1"/>
    <picture location="example2.png" tooltip="tooltip for picture #2"/>
    <picture location="example3.png" tooltip="tooltip for picture #3"/>
    etc...

  • Can anyone solve this simple MVC problem with ArrayCollection

    I have very simple application trying to understand how to apply MVC without any framework. There are quite a few exemples on the net but most do not deal with complex data.
    here is my application with 4 files: MVCtest.mxml, MyController.as, MyModel.as and MyComponent.as
    first the Model MyModel.as
    package model
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.IEventDispatcher;
    import mx.collections.ArrayCollection;
    [Event(name="ArrayColChanged", type="flash.events.Event")]
    [Bindable]
    public class MyModel extends EventDispatcher
      private static var instance:MyModel;
      public static const ARRAYCOL_CHANGED:String = "ArrayColChanged";
      private var _myArrayCol:ArrayCollection;
      public function MyModel(target:IEventDispatcher=null)
       super(target);
       instance = this;
      public static function getInstance():MyModel
       if(instance == null)
        instance = new MyModel();
       return instance;
      public function get myArrayCol():ArrayCollection
       return _myArrayCol;
      public function set myArrayCol(value:ArrayCollection):void
       _myArrayCol = new ArrayCollection(value.source);
       dispatchEvent(new Event(ARRAYCOL_CHANGED));
    then the controller: MyController.as
    package controller
    import components.MyComponent;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.IEventDispatcher;
    import model.MyModel;
    import mx.collections.ArrayCollection;
    import mx.controls.Alert;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.remoting.RemoteObject;
    public class MyController extends EventDispatcher
      [Bindable]
      public var view:MVCtest;
      [Bindable]
      public var componentView:MyComponent;
      private var _model:MyModel = MyModel.getInstance();
      public function MyController(target:IEventDispatcher=null)
       super(target);
       _model.addEventListener("ArrayColChanged", onArrayColChange);
      public function initialise(event:Event):void
       getData();
      public function getData():void
       var dataRO:RemoteObject = new RemoteObject;
       dataRO.endpoint = "gateway.php";
       dataRO.source = "MytestdbService";
       dataRO.destination = "MytestdbService";
       dataRO.addEventListener(ResultEvent.RESULT, dataROResultHandler);
       dataRO.addEventListener(FaultEvent.FAULT, dataROFaultHandler);
       dataRO.getAllMytestdb();   
      public function dataROResultHandler(event:ResultEvent):void
       _model.myArrayCol = new ArrayCollection((event.result).source);
      public function dataROFaultHandler(event:FaultEvent):void
       Alert.show(event.fault.toString());
      public function onArrayColChange(event:Event):void
       componentView.myDataGrid.dataProvider = _model.myArrayCol;
    This is the main application: MVCtest.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:controller="controller.*"
          xmlns:components="components.*"
          width="600" height="600"
          creationComplete="control.initialise(event)">
    <fx:Declarations>
      <controller:MyController id="control" view = "{this}"/>
    </fx:Declarations>
    <fx:Script>
      <![CDATA[
       import model.MyModel;
       import valueObjects.MyVOorDTO;
       [Bindable]
       private var _model:MyModel = MyModel.getInstance();
      ]]>
    </fx:Script>
    <s:VGroup paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
      <s:Label fontSize="20" fontWeight="bold" text="MVC Test with components"
         verticalAlign="middle"/>
      <components:MyComponent/>
    </s:VGroup>
    </s:Application>
    And this is the component: MyComponent.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark"
       xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
    <s:layout>
      <s:VerticalLayout paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10"/>
    </s:layout>
    <fx:Declarations>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Label fontSize="16" fontWeight="bold" text="My Component " verticalAlign="bottom"/>
    <s:DataGrid id="myDataGrid" width="100%" height="100%" requestedRowCount="4">
      <s:columns>
       <s:ArrayList>
        <s:GridColumn dataField="mystring" headerText="String"></s:GridColumn>
        <s:GridColumn dataField="myinteger" headerText="Integer"></s:GridColumn>
        <s:GridColumn dataField="myreal" headerText="Real"></s:GridColumn>
        <s:GridColumn dataField="mydate" headerText="Date"></s:GridColumn>
       </s:ArrayList>
      </s:columns>
    </s:DataGrid>
    </s:Group>
    Here is the code to generate the database:
    CREATE DATABASE mytest;
    CREATE TABLE myTestDB
          myid INT UNSIGNED NOT NULL AUTO_INCREMENT,
          mystring CHAR(15) NOT NULL,
          myinteger INT NOT NULL,
          myreal DECIMAL(6,2) NOT NULL,
          mydate DATE NOT NULL,
          PRIMARY KEY(myid)
    ) ENGINE = InnoDB;
    INSERT INTO myTestDB (mystring, myinteger, myreal, mydate) VALUES ('Test', 123, 45.67, '2012-01-01'), ('Practice', 890, 12.34, '2012-02-01'), ('Assay', 567, 78.90, '2011-10-01'), ('Trial', 111, 22.22, '2009-09-09'), ('Experiment', 333, 44.44, '1999-04-15'), ('Challenge', 555, 66.66, '2012-12-21');
    And finally here is the PHP script.
    <?php
    class myVOorDTO
      var $_explicitType = "valueObjects.myVOorDTO";
      public $myid;
      public $mystring;
      public $myinteger;
      public $myreal;
      public $mydate;
      public function __construct()
        $this->myid = 0;
        $this->mystring = "";
        $this->myinteger = 0;
        $this->myreal = 0.0;
        $this->mydate = date("c");
    class MytestdbService
      var $username = "yourusername";
      var $password = "yourpassword";
      var $server = "yourserver";
      var $port = "yourport";
      var $databasename = "mytest";
      var $tablename = "mytestdb";
      var $connection;
      public function __construct()
        $this->connection = mysqli_connect(
        $this->server, $this->username, $this->password, $this->databasename, $this->port);
    * Returns all the rows from the table.
    * @return myVOorDTO
      public function getAllMytestdb()
        $query = "SELECT * from $this->tablename";
        $result = mysqli_query($this->connection, $query);
        $results = array();
        while ($obj = mysqli_fetch_assoc($result))
          $row = new myVOorDTO();
          $row->myid = $obj['myid'] + 0;
          $row->mystring = $obj['mystring'];
          $row->myinteger = $obj['myinteger'] + 0;
          $row->myreal = $obj['myreal'] + 0.0;
          $row->mydate = new Datetime($obj['mydate']);
          array_push($results, $row);
        return $results;
    ?>
    My understanding as to what is going on is: (1) on creation complete the application launch the initialise() function of the controller (2) this function starts the remoteObject which get the data (3) once the results arrive the resultHandler store the data into the ArrayCollection of the model ***this does not work*** (4) even if part 3 did not work, the setter of the ArrayCollection in the model send an event that it has been changed (5) the controller receive this event and assigns the ArrayCollection of the model as the dataprovider for the datagrid in the compoent.
    Of course, since the ArrayCollection is null, the application gives an error as the dataProvider for the datagrid is null.
    What is missing in this application to make it work properly? I believe this is an example that could help a lot of people.
    Even if I change the setter in the model to _myArrayCol = ObjectUtil.copy(value) as ArrayCollection; it still does not work.
    Also, it seems that the remoteObject does not return a typed object (i.e. myVOorDTO) but rather generic objects. I am usually able to make this works but in this particular application I have not managed to do it. Again what's missing?
    Thanks for any help with this!

    Calendar c = GregorianCalendar.getInstance();
    c.set(Calendar.YEAR,2000);
    System.out.println(c.getActualMaximum(Calendar.WEEK_OF_YEAR));
    c.set(Calendar.YEAR,2001);
    System.out.println(c.getActualMaximum(Calendar.WEEK_OF_YEAR));But it says that 2000 has 53 weeks and 2001 has 52.

  • Flex 3 Database & Large Html Files

    Hi Guys,
    New to flex, and I have a question, any help would be much appreaciated, I have a database sql server 2005 I use web orb to connect to it throu flex, I have books stored in this database each page of a book is a seperate record and has html tags throughout it, what I would like to do is display one page at a time to the user and then have them click a button to get to the next record or page, this I could manage in a datagrid I guess but the pages of text are quite large is there a component that would better suit a large page of text such as the text component if so could you give me an example of how to bind my data to it and how to stop the html tags showing up as text, or if I could customize the layout of the datagrid that might be a better solution.
    I have posted an attempt to use a text component but have been unsuccessful thus far:
    <?xml version="1.0" encoding="utf-8"?>
            <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%" title="The Lord Is Near">
            <mx:Script>
    <![CDATA[
                    import mx.collections.ArrayCollection;
                    import AlphaOmega.ActiveRecords;
                    import AlphaOmega.Alpha_Calendar;
                    import mx.controls.TextArea;
                    public function GetTodaysLin():ArrayCollection
                            return ActiveRecords.Alpha_Calendar.findBySql("SELECT Cal_ID, Cal_Text, Cal_Date, Cal_MP3 FROM Alpha_Calendar WHERE (Cal_Date = CONVERT(VARCHAR(30), GETDATE(), 102))");
            ]]>
    </mx:Script>   
            <mx:Text htmlText="{GetTodaysLin}" width="100%" height="100%" id="Lin" />
    </mx:Panel>
    Thanks

    You seem to be using Text with htmlText property. Does that not display the HTML as expected? Remember, Flex supports a sub-set of HTML tags:
    Search for" Using tags in HTML text" in this page:
    http://livedocs.adobe.com/flex/3/html/help.html?content=textcontrols_04.html
    You could just have Next and Back buttons that populate the Text control from the next of previous item in an ArrayCollection, where the items in the ArrayCollection are objects with each page of text.
    If this post answered your question or helped, please mark it as such.

  • ArrayCollection and data retrieval

    I have been looking as to how to extract data from an
    ArrayCollection. I know this is done via the IViewCursor, but the
    only examples shown in the help files use simple arrays in the
    ArrayCollection class (one dimentional). As 99% of my
    ArrayCollections are from database queries (two dimentional), this
    does not really apply. Any examples of extracting data from a query
    call into an ArrayCollection would be greatly appreciated!

    Assuming the ArrayCollection is a list of strongly typed
    Employee objects.
    for each( var emp:Employee in empArrayCollection )
    var firstName:String = emp.fname;
    var lastName:String = emp.lname;
    var city:String = emp.address.city;

  • Is it possible to search ArrayCollection by index?

    Hi all,
    As I know, we can loop and compare each item of ArrayCollection to get correct item we want. Obveriously, the performance will get bad and it's not a wise method to search. Can we create a index for the key field of each item? Or is there any other class providing such functionality?
    Thanks,

    When you say "an index" are you talking as a in a database table index?  I.e. something that can quicken a search?
    I am trying to understand your desire and I think what I am hearing is that you have an ArrayCollection contain a number of Objects.   When you want to find a particular Object, you have found that one way to locate the desired instance is to walk through each element of the ArrayCollection and ask "does this element equal the key of the object I am looking for?".   I think you are concerned by the amount of time that this may take.
    Going back decades to my computing science knowledge, this would be an O(n) algorithm where n is the number of elements in the array.
    Now, if there were an "index" (ala databases) on the data, then if this index were Sorted, you would be able to find your match in O(log n)
    You may pay an O(n log n) cost to sort the index when the data structure is created but if you have a large number of searches then it may pay for itself.
    I am not aware of any function that will support you on this out of the box (but that doesn't mean there isn't, only that I don't know about it.
    I would also truthly ask yourself "is it worth the cost?".   How many elements will you have in a typical array?  How often do you anticipate locating an entry in that array?
    Neil

  • Return results from ADEP in AS3 Arrays, not ArrayCollections

    Hi all,
    Is there any way to force ADEP to return results from data services in simple AS3 Arrays, not ArrayCollections? Here are my situation:
    In my project I use ADEP Data Management Services. To connect to ADEP services we use RTMP channel defined in services-config.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <services-config>
         <services>
              <service-include file-path="remoting-config.xml" />
              <service-include file-path="proxy-config.xml" />
              <service-include file-path="messaging-config.xml" />
              <service-include file-path="data-management-config.xml" />
              <service-include file-path="managed-remoting-config.xml" />
              <service class="fiber.data.services.ModelDeploymentService" id="model-deploy-service" />
              <default-channels>
                   <channel ref="my-rtmp"/>
              </default-channels>
         </services>
         <channel-definition id="my-rtmp" class="mx.messaging.channels.RTMPChannel">
              <endpoint url="rtmp://{server.name}:1000" class="flex.messaging.endpoints.RTMPEndpoint"/>
              <properties>
                   <idle-timeout-minutes>20</idle-timeout-minutes>
                   <block-rtmpt-polling-clients>true</block-rtmpt-polling-clients>
                   <rtmpt-poll-wait-millis-on-client>0</rtmpt-poll-wait-millis-on-client>
              </properties>
         </channel-definition>
    </services-config>
    To manage data in database we defined data services in data-management-config.xml like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <service id="data-service" class="flex.data.DataService">
        <adapters>
            <adapter-definition id="java-dao" class="flex.data.adapters.JavaAdapter"/>
            <adapter-definition id="mr-java-dao" class="flex.data.adapters.ManagedRemotingDataAdapter" />
            <adapter-definition id="actionscript" class="flex.data.adapters.ASObjectAdapter" default="true"/>
        </adapters>
        <default-channels>
            <channel ref="my-rtmp"/>
        </default-channels>
        <destination id="SomeProduct.SomeItems">
            <adapter ref="java-dao" />
            <properties>
                <source>flex.data.assemblers.SQLAssembler</source>
                <scope>application</scope>
                <metadata>
                    <identity property="ID" />
                </metadata>
                <server>
                    <database>
                        <datasource>java:comp/env/jdbc/SP</datasource>
                    </database>
                    <actionscript-class>com.somecompany.classes.SomeCoolClass</actionscript-class>
                    <create-item>
                        <procedure name="SomeItems_Insert">
                            <procedure-param property-value="#Session_ID#" />
                            <procedure-param property-value="#Division_ID#" />
                            <procedure-param property-value="#Salesrep_ID#" />
                            <procedure-param property-value="#Area_Code#" />
                            <procedure-param property-value="#Item_ID#" />
                        </procedure>
                        <id-query>SELECT IDENT_CURRENT('Work_Area_Item')</id-query>
                    </create-item>
                    <fill>
                        <name>all</name>
                        <procedure name="SomeItems_Get">
                            <procedure-param property-value="#Session_ID#" />
                            <procedure-param property-value="#Last_Sync_Time#" />
                        </procedure>
                    </fill>
                    <update-item>
                        <procedure name="SomeItems_Update">
                            <procedure-param property-value="#Session_ID#" />
                            <procedure-param property-value="#Division_ID#" />
                            <procedure-param property-value="#Salesrep_ID#" />
                            <procedure-param property-value="#Area_Code#" />
                            <procedure-param property-value="#Item_ID#" />
                       </procedure>
                    </update-item>
                    <delete-item>
                        <procedure name="SomeItems_Delete">
                            <procedure-param property-value="#Session_ID#" />
                            <procedure-param property-value="#Item_ID#" />
                        </procedure>
                    </delete-item>
                </server>
            </properties>
        </destination>
    </service>
    By default, ADEP returns results from SomeProduct.SomeItems destination to Flex side as ArrayCollection of SomeCoolClass instances but I need the data to be returned in simple AS3 Arrays. Recently, I found that there is small optional serialization configuration in channel-definition that should resolve my problem. So I updated my channel-definition in services-config.xml to this:
    <channel-definition id="my-rtmp" class="mx.messaging.channels.RTMPChannel">
         <endpoint url="rtmp://{server.name}:1000" class="flex.messaging.endpoints.RTMPEndpoint"/>
         <properties>
              <serialization>
                   <legacy-collection>true</legacy-collection>
              </serialization>
              <idle-timeout-minutes>20</idle-timeout-minutes>
              <block-rtmpt-polling-clients>true</block-rtmpt-polling-clients>
              <rtmpt-poll-wait-millis-on-client>0</rtmpt-poll-wait-millis-on-client>
         </properties>
    </channel-definition>
    However, result are still returned in ArrayCollections.
    Any ideas?
    Thanks in advance

    Thom Parker answered this here: http://forums.adobe.com/message/2614570#2614570
    Answer copied below:
    "The problem is that when the focus is on the text box
    it's in edit mode. It's only displaying the value interactively entered by
    the user, or as a consequence of the change event.  What you need to do is
    force the focus off of the text box in code.  You can do a little trick
    where you bounce it to a tiny transparent field, which then bounds the focus
    back so it doesn't look like the focus changed."
    What I ended up doing was calling up the dialog box, then using setfocus with no parameters to remove focus from the field, as follows:
    this.rawValue = this.dialogBoxFunction(this.rawValue); // passing current value so dialog box defaults to that value
    xfa.host.setFocus();
    Cheers,
    Marty.

  • Access DataField in Itemrenderer when submitting to Database

    Hello,
    I'm really stuck on this one. I have setup an Itemrenderer in a Datagrid which manages a DateField. Users can enter a date and other values directly in the datagrid. When they click 'submit', I want to populate a row in a database and I have setup a service for this. A row is created in the db as expected however the date is not populated despite users having entered a value. Below is a code snippet:
    Datagrid
    <s:GridColumn dataField="datf" headerText="Period From" rendererIsEditable="true">
         <s:itemRenderer>
              <fx:Component>
                   <s:GridItemRenderer dataChange="updateRenderer()">
                        <fx:Script>
                             <![CDATA[
                                       public function updateRenderer():void {
                                            periodFrom.text = outerDocument.dtf1.format(data.datf);
                                       private function dateField_labelFunc(item:Date):String {
                                            periodFrom.text = outerDocument.dtf1.format(item);
                                            return outerDocument.dtf1.format(item);
                             ]]>
                        </fx:Script>
                             <mx:DateField horizontalCenter="0" verticalCenter="0" width="90%" id="periodFrom" labelFunction="dateField_labelFunc"/>
                   </s:GridItemRenderer>
              </fx:Component>
    </s:itemRenderer>
    </s:GridColumn>
    Handler
    protected function createBillResult_resultHandler(event:ResultEvent):void
                                            var dataProvider = itemsDg.dataProvider;
                                            var item = null;
                                            for (var i:int = 0; i < dataProvider.length; i++){
                                                      item = dataProvider.getItemAt(i);
                                                      trace(item.datf); <--- THIS IS 'UNDEFINED'
                                                      billItems.days = item.days;
                                                      billItems.ratu = item.ratu;
                                                      billItems.lnid = item.lnid;
                                                      trace(billItems.datf = dtf2.format(item.datf));
                                                      createBillItemsResult.token = billingService.createBillItems(billItems);
    I would have thought that I can access the value from the itemrenderer using the dataField property like I do with the other items.
    Please, please, please help.
    Brian

    This error "TypeError: Error #1009: Cannot access a property or method of a null object reference" usually show when you are trying to set something that doesn't exist at the time of calling.
    I create a test code and it works for me. Try to replicate you issue here:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.controls.Alert;
                // Data includes URL to album cover.
                [Bindable]                       
                private var initDG:ArrayCollection = new ArrayCollection([
                    { Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99, datf:'01/01/2012'},
                    { Artist:'Pavement', Album:'Brighten the Corners',     Price:11.99, datf:'01/01/2012'}
                private function addEmptyRow():void{
                    myGrid.dataProvider.addItem({
                        'Artist':'',
                        'Album':'',
                        'Price':0,
                        'datf':''
                private function showData():void{
                    Alert.show('Done');
            ]]>
        </fx:Script>
        <s:VGroup>
        <s:DataGrid id="myGrid" dataProvider="{initDG}" width="100%" variableRowHeight="true" editable="true">  
            <s:columns>
                <s:ArrayList>
                    <s:GridColumn dataField="Artist"/>
                    <s:GridColumn dataField="Album"/>
                    <s:GridColumn dataField="Price"/>
                    <s:GridColumn dataField="datf" headerText="Period From" rendererIsEditable="true">
                        <s:itemRenderer>
                            <fx:Component>
                                <s:GridItemRenderer>
                                    <fx:Script>
                                        <![CDATA[
                                            public function updateData():void {
                                                data.datf = periodFrom.selectedDate;
                                        ]]>
                                    </fx:Script>
                                    <mx:DateField horizontalCenter="0" verticalCenter="0" width="90%" id="periodFrom" formatString="MM/DD/YYYY" text="{data.datf}" change="updateData()" />
                                </s:GridItemRenderer>
                            </fx:Component>
                        </s:itemRenderer>
                    </s:GridColumn>
                </s:ArrayList>
            </s:columns>
        </s:DataGrid>
        <s:Button label="Add Row" click="addEmptyRow()" />
        <s:Button label="submit" click="showData()" />
        </s:VGroup>
    </s:Application>

  • 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

  • LCDS commit error from arraycollection

    Hi all,
    I am attempting to hook Flex up to the LCDS engine installed
    with CF8. I can get the ds.fill() method to populate an
    ArrayCollection just fine, pump the data out in a DataGrid and
    shows perfectly. However, when I update a record in the datagrid I
    get an error indicating that "Error during update: The OLDBEAN
    argument passed to the update function is not of type" and then it
    says my CFC type.
    I changed to code to set autoCommit to false and update one
    entrry via code then manually call commit, and this works fine,
    although I did have to cast the single record to my data type (it
    was a generic Object). Setting it back and debugging shows that all
    of the records in my ArrayCollection are typed as generic Object's
    not as my defined data type.
    My question is: how do I get the ds.fill() method to return
    the correctly typed objects (I am using the CF8 wizard-generated
    CRUD arguments)
    OR
    How can I programatically convert the contents of the
    ArrayCollection to the required type "on-the-fly" before calling
    ds.commit()?
    Hoping somebody can help, this is driving me nuts!
    Just as a final thought, does this indicate a bug in the CF
    CRUD generation wizard or am I just doing it wrong?
    Cheers,
    Owen West
    HNE Health
    [email protected]

    Which the information provide it's hard to troubleshoot because there's no Oracle related information.
    What's your Oracle version? do you have enough space on rollback segment tablespace or undo tablespace (9i and above)
    Any error in your database's alert log file?

  • (HTTPService - result="" - to ArrayCollection) -  a question for super expert ;)

    Firstly look at my example then you will read the question:
    Look at example below - I'm using HTTPService component to retrieve data from SQL database
    (read_record.php is generating nice and tidy xml file with my data)
    <!-- (A) read  -->
    <!-- =================== HTTP SERVICE (read_record) ============================ -->
        <mx:HTTPService id="readTimed"
            url="http://www.pudelek.pl/SCRIPT/A/read_record.php"
            result="patient(event)">
        </mx:HTTPService>
    Then 'result' is calling a function patient() which task is to assign 'event.result'
    to ArrayCollection called 'A_patient_dp'  (this ArrayCollection is a data provider
    for a specific data grid)
    private function patient(event:ResultEvent):void {
        trace("A - PATIENT - loaded...")
        trace(event.result.patient.patient)
        A_patient_dp = event.result.patient.patient
    Everything looks great here, data grid shows all the data from xml file generated
    by read_record.php
    and now is my problem :
    I don't want to display all the data, I want HTTPService to retrieve only particular data
    which are described by variable {parametr} - this var is generated by my application
    I've dond it this way:
    <!-- (A) MAP POSITIONING -->
    <!-- =================== HTTP SERVICE (read_record) ============================ -->
        <mx:HTTPService id="readRequestA"
            url="http://www.pudelek.pl/SCRIPT/A/A_send_read_record.php"
                useProxy="false"
                method="POST">
            <mx:request xmlns="">
                <idstaff>{parametr}</idstaff>
            </mx:request>
        </mx:HTTPService>
    I'm looking into source of 'A_send_read_record.php' in the internet browser and I see
    exact data tree (filtered) which I need.
    The problem here is : how to call function patient(event:ResultEvent) and give it
    data from the event to be assigned to ArrayCollection - like in first example.
    Thanks for all the ideas !!

    If this post answers your question or helps, please mark it as such.
    Greg Lafrance - Flex 2 and 3 ACE certified
    www.ChikaraDev.com
    Flex / AIR Development, Training, and Support Services
    <mx:HTTPService id="readRequestA"
    url="http://www.pudelek.pl/SCRIPT/A/A_send_read_record.php"
    useProxy="false" result="patient(event)" method="POST">
      <mx:request xmlns="">
        <idstaff>{parametr}</idstaff>
      </mx:request>
    </mx:HTTPService>

  • 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

  • Have a combobox pre-filled using data from database

    What would be a recommended method to have a combobox
    pre-filled using data from database?

    You can load an Array with the data returned from your
    database and bind to that array as the dataProvider for the
    comboBox.
    [Bindable]
    private var myArrayDP:Array = new Array();
    //Load the array with your returned data.
    <mx:ComboBox dataProvider="{this.myArrayDP}">
    </mx:ComboBox>
    Using an ArrayCollection however is often better if you want
    changes to the dataProvider to automatically reflect in the
    ComboBox.

Maybe you are looking for