Thanks Maury and Clint! This makes sense. We are assigning functions to the result and fault events of the RemoteObject tag. So they will run at that time.
So we can take the results of the event and run the function onGetJobResult() passing the event into this function by placing it in the parentheses. When the function fires we are taking the results and passing it in and converting to an array... So the re: and fe: are just parameters that the function is expecting and the colon is defining it as a ResultEvent or FaultEvent so the function can work with it.... DO YOU SEE THE BIG LIGHT BULB OVER MY HEAD???? :) Wow... makes sense. Thanks again... I am going to break this down and write it out in a way I can understand. Chad > -----Original Message----- > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of maury.sword > Sent: Thursday, March 22, 2007 7:21 PM > To: [email protected] > Subject: [flexcoders] Re: flex remoting and query > > Chad, > > The code that I sent is just the listener/event handler for the > results that are returned from the CFC. I'm not using binding in my > example. I'm just assigning the results to the datagrid's > dataProvider. > > You need to add result="onListResult(event)" to your RemoteObject. > > Try this, I've also added a fault handler: > > <mx:Script> > <![CDATA[ > > import mx.controls.Alert; > import mx.rpc.events.ResultEvent; > import mx.rpc.events.FaultEvent; > > private function onGetJobResult(re:ResultEvent):void { > dgJob.dataProvider = ArrayCollection(re.result); > } > > private function onGetJobFault(fe:FaultEvent):void { > Alert.show(fe.fault.message); > } > > ]]> > </mx:Script> > > <mx:RemoteObject id="roJob" destination="ColdFusion" source="test" > endpoint="http://demo.dev/flex2gateway/" > result="onGetJobResult(event)" > fault="onGetJobFault(event)"> > <mx:method name="getJob"> > <mx:arguments> > <jobNum>{jobNum.text}</jobNum> > </mx:arguments> > </mx:method> > </mx:RemoteObject> > > <mx:DataGrid id="dgJob" x="10" y="274" width="356" > > <mx:columns> > <mx:DataGridColumn headerText="Job Number" > dataField="JobNum"/> > <mx:DataGridColumn headerText="Job Name" > dataField="JobName"/> > <mx:DataGridColumn headerText="Job Description" > dataField="JobDescription"/> > </mx:columns> > </mx:DataGrid> > > > --- In [email protected], "Chad Gray" <[EMAIL PROTECTED]> wrote: > > > > Thanks Clint and Maury, > > > > Im afraid it don't completely understand the lingo "bind the result > to an array". > > > > I get an error when I run the program > > ReferenceError: Error #1065: Variable is not defined. > > > > I think my datagrid datafields are wrong or the function is not > running. > > > > So on the function code you sent here is what I think is happening > and how I reformatted it for my code: > > protected function onListResult(roGetJob:ResultEvent):void { > > dgJob.dataProvider = ArrayCollection(roGetJob.result); } > > > > > > Here is my romoteOject code: > > <mx:RemoteObject id="roGetJob" destination="ColdFusion" > source="test" endpoint="http://demo.dev/flex2gateway/" > > > <mx:method name="getJob"> > > <mx:arguments> > > <jobNum>{jobNum.text}</jobNum> > > </mx:arguments> > > </mx:method> > > </mx:RemoteObject> > > > > > > Here is my data grid code: > > <mx:DataGrid id="dgJob" x="10" y="274" width="356" dataProvider=""> > > <mx:columns> > > <mx:DataGridColumn headerText="Job Number" > dataField="JobNum"/> > > <mx:DataGridColumn headerText="Job Name" > dataField="JobName"/> > > <mx:DataGridColumn headerText="Job Description" > dataField="JobDescription"/> > > </mx:columns> > > </mx:DataGrid> > > > > > > Here is my cfc function > > <cffunction name="getJob" returnType="query" output="no" > access="remote"> > > <cfargument name="jobNum" type="numeric" required="yes"> > > > > <cfquery datasource="database" name="getJobInfo"> > > SELECT JobNum, JobName, JobDescription > > FROM Job > > WHERE JobNum = #arguments.jobNum# > > </cfquery> > > > > <cfreturn getJobInfo> > > </cffunction> > > > > > > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com > Yahoo! Groups Links > > >

