6 Replies Latest reply on Aug 18, 2006 3:17 PM by targetplanet

    Help with Remoting in Flex 2 PLEASE!!!!

    targetplanet Level 1
      I can't figure out how to send data to a cfc from flex, using my remoteObject.
      I can send simple data, 1 or 2 params, but I need to send data that is in a Model Object.
      So here is my function that calls the remote edit function, and tried to send the data that is sent in an event to the function.
      private function regUpdate(event:RegEdit):void{
      var edit:Object = event.itemReturn;
      //Alert.show(edit.level);
      regService.editReg(edit);
      }

      When I call the editReg with the edit Object as a param, I get this Error

      faultCode:Server.Processing
      faultSrting:'java.lang.StackOverflowError
      faultDetail:'null'

      In Flash remoting, I could just send an Object and then access it in the cfc using Arguments.param
      But I guess this is not the case for Flex.
      But it doesn't seem to matter what is in my cfc, if I try and pass that Object, it errors.
      What am I missing? I have been searching for an answer to this all morning, with no results.
      Where are all the good Flex examples....

      Please help
      My project is due Monday!!!

        • 1. Re: Help with Remoting in Flex 2 PLEASE!!!!
          peterent Level 2
          What version of CF do you have? Is it CF 7.0.2?
          • 2. Re: Help with Remoting in Flex 2 PLEASE!!!!
            targetplanet Level 1
            Yea it's 7,0,2,142559
            • 3. Re: Help with Remoting in Flex 2 PLEASE!!!!
              peterent Level 2
              Good. In your ActionScript class which corresponds to the CFCs you are trying to pass back and forth, make sure you have this in the ActionScript class:

              [RemoteClass(alias="your.cfc.here")]

              This enables ActionScript objects to be mapped to CFCs. You can use Flex Builder's CF wizard to create an ActionScript class from a CFC or vice-versa.
              • 4. Re: Help with Remoting in Flex 2 PLEASE!!!!
                targetplanet Level 1
                hmm, I guess I know less then I thought.
                When you say ActionScript class that corresponds to the CFC, what are you referencing?
                I am calling the service from an mxml file. The data is created in a sub componet of that mxml file, and passed to the parent in an event.
                Should I be storing my data in an .as file?

                here is the code for the mxml file


                <mx:Panel xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns:is="components.reg.*" layout="horizontal" title="Registrations" titleStyleName="ttl" initialize="init()">
                <mx:Metadata>
                [RemoteClass(alias="zrPortal.services.reg")]
                </mx:Metadata>
                <mx:Script>
                <![CDATA[
                import events.RegEdit;
                import mx.collections.ArrayCollection;
                import events.GridItemSelected;
                import mx.controls.Alert;
                import mx.rpc.events.ResultEvent;

                [Bindable]
                private var regData:ArrayCollection;
                [Bindable]
                private var trekData:ArrayCollection;
                [Bindable]
                public var lInfo:Object;
                [Bindable]
                private var regItemData:Object;
                public function init():void{
                regService.getReg(lInfo.level,lInfo.rId);
                }
                public function handleRegResult(event:ResultEvent):void{
                regData = event.result as ArrayCollection;
                }
                public function handleTrekResult(event:ResultEvent):void{
                trekData = event.result as ArrayCollection;
                }
                private function regHandler(event:GridItemSelected):void{
                regItemData = event.itemSelected;
                trekService.getTreks(event.itemSelected.regId);
                }
                //edit function
                private function regUpdate(event:RegEdit):void{
                var edit:Object = event.itemReturn;
                //Alert.show(edit.level);
                regService.editReg(edit);

                }
                private function regAdd():void{

                }
                private function regDel():void{

                }
                ]]>
                </mx:Script>
                <mx:RemoteObject
                id="regService"
                destination="ColdFusion"
                source="zrPortal.services.reg"
                showBusyCursor="true">
                <mx:method name="getReg" result="handleRegResult(event)" fault="Alert.show(event.fault.message)"/>
                <mx:method name="editReg" result="handleRegResult(event)" fault="Alert.show(event.fault.message)"/>
                </mx:RemoteObject>
                <mx:RemoteObject
                id="trekService"
                destination="ColdFusion"
                source="zrPortal.services.RegTrek"
                showBusyCursor="false">
                <mx:method name="getTreks" result="handleTrekResult(event)" fault="Alert.show(event.fault.message)"/>
                </mx:RemoteObject>

                <is:RegList width="375" regData="{regData}" itemSelected="regHandler(event)"/>
                <mx:VBox>
                <mx:LinkBar dataProvider="{regContent}"/>
                <mx:ViewStack id="regContent"
                x="0" y="5"
                paddingBottom="0"
                paddingLeft="0"
                paddingRight="0"
                paddingTop="0"
                resizeToContent="true" width="100%">
                <is:RegData id="regdata" label="Reg Data" iData="{regItemData}" lInfo="{lInfo}" updateReg="regUpdate(event)" addReg="regAdd()" deleteReg="regDel()"/>
                <is:TrekData id="trekdata" label="Tec-Treks" iData="{trekData}"/>
                </mx:ViewStack>
                <is:RegFooter id="footer" iData="{regItemData}"/>
                </mx:VBox>
                </mx:Panel>
                • 5. Re: Help with Remoting in Flex 2 PLEASE!!!!
                  Simeon Bateman Level 2
                  Well the trick is that cf has some neat stuff for automatically mapping cfc to as objects. So then you can use typed properties in your as object which tends to make things work out better.

                  You might try taking out the cfargument tags in your function and then adding a cfmail tag to send you a dump of the arguments struct. This will allow you to see what cf is recieving when flex sends it up.

                  If still get the error then the problem is in how you are calling cf and the peices in between.
                  • 6. Re: Help with Remoting in Flex 2 PLEASE!!!!
                    targetplanet Level 1
                    Yea it doesn't like something about the object I am trying to send, because it errors no matter what I do in the cfc function.
                    Do you have any idea what the java.lang.StackOverflowError refers to, or is it a general error?
                    Thanks for the help