2 Replies Latest reply on Nov 25, 2009 5:49 PM by asaad970

    Cant Update record

    asaad970 Level 1

      i get this error ArgumentError: updateItem called with an item which is not managed on this client: myCompInfRPCDataManager.

      whin i try to call update service

      this is my code

       

      <?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/halo"
                     minWidth="1024" minHeight="768"
                     skinClass="skins.appskin" pageTitle="Site Control Panel  لوحة تحكم الموقع" xmlns:valueObjects="valueObjects.*" xmlns:companies_infservice="services.companies_infservice.*">
          <s:layout>
              <s:VerticalLayout/>
          </s:layout>
          <fx:Script>
              <![CDATA[
                  import mx.controls.Alert;
                  import mx.events.FlexEvent;

       


                  protected function button_clickHandler(event:MouseEvent):void
                  {
                      getcompanies_infResult.token = companies_infService.getcompanies_inf(parseFloat(comp_idTextInput.text));
                  }

       


                  protected function recCount_creationCompleteHandler(event:FlexEvent):void
                  {
                      countResult.token = companies_infService.count();
                  }
                 
                 
                  protected function newb1_clickHandler(event:MouseEvent):void
                  {   
                      /* var item:MyCompInf = new MyCompInf(); */
                      var item:Object = new Object();
                      item.comp_id = int(comp_idTextInput2.text);
                      item.adress = adressTextInput.text;
                      item.aboutUs = aboutUsTextInput.text;
                      item.ename = enameTextInput.text;
                      item.aname = anameTextInput.text;
                      item.City = cityTextInput.text;
                      item.eaboutUs = eaboutUsTextInput.text;
                      item.country = countryTextInput.text;
                      Alert.show(item.ename);
                      createcompanies_infResult.token = companies_infService.createcompanies_inf(item);
                  }
                  protected function clearb1_clickHandler(event:MouseEvent):void
                  {   
                      /* comp_idTextInput.text="";
                      adressTextInput.text="";
                      aboutUsTextInput.text="";
                      enameTextInput.text="";
                      anameTextInput.text="";
                      cityTextInput.text="";
                      eaboutUsTextInput.text="";
                      countryTextInput.text=""; */
                 
                  }
                 
                  protected function delateb1_clickHandler(event:MouseEvent):void
                  {
                      deletecompanies_infResult.token = companies_infService.deletecompanies_inf(int(comp_idTextInput.text));
                  }

       


                  protected function saveb1_clickHandler(event:MouseEvent):void
                  {   
                      //Alert.show(item.comp_id);
                       var item:Object = new Object();
                      /* item.push(int(comp_idTextInput2.text),adressTextInput.text,
                          aboutUsTextInput.text,enameTextInput.text,anameTextInput.text,
                          cityTextInput.text,eaboutUsTextInput.text,countryTextInput.text); */
                      item.comp_id = int(comp_idTextInput2.text);
                      item.adress = adressTextInput.text;
                      item.aboutUs = aboutUsTextInput.text;
                      item.ename = enameTextInput.text;
                      item.aname = anameTextInput.text;
                      item.City = cityTextInput.text;
                      item.eaboutUs = eaboutUsTextInput.text;
                      item.country = countryTextInput.text;
                     
                      //Alert.show(item.comp_id);
                      updatecompanies_infResult.token = companies_infService.updatecompanies_inf(item);
                      //companies_infService.commit(item);
                  }

       

       

       

              ]]>
          </fx:Script>
          <fx:Declarations>
              <companies_infservice:Companies_infService id="companies_infService"
                                                         fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
                                                         showBusyCursor="true"/>
              <s:CallResponder id="getcompanies_infResult" result="myCompInf = getcompanies_infResult.lastResult as MyCompInf"/>
              <valueObjects:MyCompInf id="myCompInf" comp_id="{parseFloat(comp_idTextInput.text)}"/>
              <s:CallResponder id="countResult"/>
              <s:CallResponder id="createcompanies_infResult"/>
              <s:CallResponder id="deletecompanies_infResult"/>
              <s:CallResponder id="updatecompanies_infResult"/>
              <s:CallResponder id="updatecompanies_infResult2"/>
             
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <s:HGroup height="10%"
                    width="100%" styleName="hd1"
                    color="#3E3A3A" id="hd1" >
             
              <s:HGroup width="100%" height="100%" >
                 
                  <mx:Form height="100%" width="90" paddingLeft="3" paddingRight="3" paddingBottom="3" paddingTop="3" dropShadowVisible="true" id="logoform" label="Members" backgroundColor="#FFFFFF"
                           backgroundAlpha="1.0" contentBackgroundColor="#F8F8FB" contentBackgroundAlpha="0.28">
                      <mx:Image width="80" height="100%" source="@Embed('imgs/LOGO3.png')"
                                scaleContent="true" maintainAspectRatio="false"/>
                  </mx:Form>
                 
                  <s:Label text="Abra Al Moohit Commercial Meaditor"
                           textAlign="left" width="371" fontWeight="bold"
                           fontStyle="normal" color="#ED9159" height="100%" fontSize="18"
                           backgroundAlpha="1.0" fontFamily="Verdana" verticalAlign="bottom"/>
                  <s:Label text="L.L.C"
                           textAlign="left" width="100%" fontWeight="bold"
                           fontStyle="normal" color="#ED9159" height="100%" fontSize="12"
                           backgroundAlpha="1.0" fontFamily="Verdana" verticalAlign="bottom"/>
                  <!--<containers:loginPanel width="100%" height="100%"/>-->
                 
              </s:HGroup>
          </s:HGroup>
          <mx:Accordion width="100%" height="100%" color="#C01F39" textAlign="center" fontWeight="bold" fontSize="11" fontFamily="Verdana" dropShadowVisible="false" contentBackgroundColor="#364E76" contentBackgroundAlpha="0.26" borderVisible="true">
              <mx:Canvas label="Company Main Inf." width="100%" height="100%" id="rmenu" textAlign="center" color="#53595A" dropShadowVisible="true" borderVisible="true" contentBackgroundColor="#364E76">
                  <s:HGroup width="100%" height="100%">
                     
                     
                      <mx:VRule height="100%" width="5" baseColor="#CCCCCC"/>
                  <s:VGroup width="15%" height="100%" left="5" top="5" fontSize="9" contentBackgroundAlpha="1.0">
                      <s:Button label="Company Main Inf" width="100%"/>
                      <s:Button label="Button" width="100%"/>
                      <s:Button label="Button" width="100%"/>
                      <s:Button label="Button" width="100%"/>
                      <s:Button label="Button" width="100%"/>
                      <s:Button label="Button" width="100%"/>
                      <s:Button label="Button" width="100%"/>
                  </s:VGroup>
                  <mx:VRule height="100%" width="5" baseColor="#CCCCCC"/>
                  <s:VGroup y="179" height="100%" right="5" left="150" width="100%">
                      <mx:Form defaultButton="{button}" width="100%" paddingBottom="5">
                          <s:HGroup width="100%" contentBackgroundAlpha="0.99" contentBackgroundColor="#FBFBFC">
                              <mx:FormItem label="Comp_id">
                                  <s:TextInput id="comp_idTextInput"/>
                              </mx:FormItem>
                              <s:Button label="Getcompanies_inf" id="button" click="button_clickHandler(event)"/>   
                              <s:Button label="Clear" id="clearb1" click="clearb1_clickHandler(event)"/>
                              <s:Button label="New" id="newb0" click="newb1_clickHandler(event)"/>
                              <s:Button label="Save" id="saveb1"  click="saveb1_clickHandler(event)"/>
                              <s:Button label="Delete" id="delateb1" click="delateb1_clickHandler(event)"/>
                             
                          </s:HGroup>
                         
                      </mx:Form>
                      <mx:HRule width="100%"/>
                      <mx:Form contentBackgroundAlpha="1.0" contentBackgroundColor="#ECEFF3" width="90%" height="100%" paddingTop="5" paddingBottom="5">
                          <s:HGroup width="100%">
                              <mx:FormItem label="Comp_id">
                                  <s:TextInput id="comp_idTextInput2" text="{myCompInf.comp_id}"/>
                                 
                              </mx:FormItem>
                              <mx:Spacer width="70%"/>
                              <mx:FormItem label="No Of Rec.">
                                  <s:Label text="{countResult.lastResult}" id="recCount" creationComplete="recCount_creationCompleteHandler(event)"/>
                              </mx:FormItem>   
                          </s:HGroup>
                         
                          <mx:FormItem label="Ename">
                              <s:TextInput id="enameTextInput" text="@{myCompInf.ename}" width="400"/>
                          </mx:FormItem>
                          <mx:FormItem label="Aname">
                              <s:TextInput id="anameTextInput" text="@{myCompInf.aname}" width="400"/>
                          </mx:FormItem>
                          <mx:FormItem label="Country">
                              <s:TextInput id="countryTextInput" text="@{myCompInf.country}" width="200"/>
                          </mx:FormItem>
                          <mx:FormItem label="City">
                              <s:TextInput id="cityTextInput" text="@{myCompInf.City}" width="200"/>
                          </mx:FormItem>
                          <mx:FormItem label="Adress">
                              <s:TextInput id="adressTextInput" text="@{myCompInf.adress}" width="400"/>
                          </mx:FormItem>
                          <mx:FormItem >
                              <mx:RichTextEditor id="eaboutUsTextInput" title="About Us" height="225"
                                                 borderAlpha="0.15" y="77" text="@{myCompInf.eaboutUs}" left="15" right="15" width="700" textAlign="left"/>
                             
                             
                          </mx:FormItem>
                          <mx:FormItem >
                              <mx:RichTextEditor  id="aboutUsTextInput" title="نبـذة عنـا" height="225"
                                                 borderAlpha="0.15" y="77" text="@{myCompInf.aboutUs}" left="15" right="15" width="700" textAlign="right"/>
                             
                          </mx:FormItem>
                         
                      </mx:Form>
                  </s:VGroup>
                  <!--<local:IFrame id="test1"
                                label="Google"
                                source="http://www.google.ae"
                                width="100%"
                                height="100%"
                                />-->
                  </s:HGroup>
              </mx:Canvas>
              <mx:Canvas label="Our Prodacts" width="100%" height="100%">
              </mx:Canvas>
              <mx:Canvas label="Our Services" width="100%" height="100%">
              </mx:Canvas>
             
              <mx:Canvas label="Our Support" width="100%" height="100%">
              </mx:Canvas>
             
          </mx:Accordion>
         
         
      </s:Application>

       

      please help i really dont understand what is the problem the delete and add new calls are working fine

      i use coldfusion9 and mysql database and i dont think there is problem in the cfc file

        • 1. Re: Cant Update record
          SrinivasAnnam Adobe Employee

          Hi,

           

             Did you generate this CFC using the new sample generation dialog in Flash Builder 4 ? If so, Client Side Data Management is automatically enabled in this workflow.

           

             Client Side Data Management (CDMS) is used to manage modifications to data locally and then automatically do batch update or revert. So, when CDMS is enabled, it expects the object ( row of data ) to be on client before you can update it. As per your code, I don't see you fetching the rows at all. So, you don't have the reference to the object to be updated. That is why you are getting this error.

           

             Correct way to do this will be to get the data on to client and then call update on one of the rows of that array or disable data management using below steps:

           

             1. Right-click on the "Companies" data-type and choose "Enable Data Management"

             2. Click on "Next" button

             3. Choose "None" in all four combos.

           

             Please let us know if this does not work. We will give you other workarounds.

           

          Regards

          Srinivas Annam

          http://srinivasannam.wordpress.com

          • 2. Re: Cant Update record
            asaad970 Level 1

            Thanks for responding , but i did what you said and the error not accure again but i cant see any data whin i get the company info by id in the application form , do i have to declare an instanse of the value abject befor any service call , how i can enable the data management also , i really want to do that by the correct way ,plz help