Changes between Version 3 and Version 4 of HowTos/HowToUseRemoting
- Timestamp:
- 02/04/10 05:44:17 (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
HowTos/HowToUseRemoting
v3 v4 167 167 }}} 168 168 169 We define our Remote Object service with the "mx:RemoteObject" tag. In this tag, we called the standard "!ColdFusion" service defined in your remoting-config.xml in your flex folder on the !ColdFusion server. The source defines the specific cfc we will are calling which in withour MG3 app will always be the !RemotingService.cfc. When the result comes back, we have a function called "resultHandler()" which will process the data.169 We define our Remote Object service with the "mx:RemoteObject" tag. In this tag, we called the standard "!ColdFusion" service defined in your remoting-config.xml in your flex folder on the !ColdFusion server. The source defines the specific cfc we are calling which in our MG3 app will always be the !RemotingService.cfc. When the result comes back, we have a function called "resultHandler()" which will process the data. 170 170 171 171 When this Flex application runs, we start off with calling the init() function with our creationComplete() located near the top of the file. The init() makes the remote object call to the "executeEvent" method located in the !RemotingService.cfc. That method has 3 arguments. The first argument is the event string. This is exactly the same value you would use in the url in a normal MG3 application. The second argument is are values you need to submit with the event. In this example we didn't have any values to submit, but for future reference you simply can submit values as an object of name/value pairs like so, {Param1:"Hi!", Param2:76}. The third argument is the MG3 event object key we want back. MG normally returns lots of things in the "event" object. For our purposes, we just want the "users" object. … … 220 220 }}} 221 221 222 The $(document).ready() fires up after the page is loaded. We start off by setting some variables. We will call the !RemotingService.cfc directly by url. When we do this, we can also specify the return format. The default is WDDX but the JSON format is prefer for AJAX applications. The "queryFormat=column" provides some additional information which we use in handling the loop later on.222 The $(document).ready() fires up after the page is loaded. We start off by setting some variables. We will call the !RemotingService.cfc directly by url. When we do this, we can also specify the return format. The default is WDDX but the JSON format is preferred for AJAX applications. The "queryFormat=column" provides some additional information which we use in handling the loop later on. 223 223 224 224 Like the previous Flex example, we have two critical variables to define. The first is the MG3 "event name" we wish to call and the second is the event object key (basically the returned values) we need back for the remoting call. We can also set additional arguments if required. 225 225 226 If the call is successful, then we loop over the result and build out a html string of list items "<li>". This html string is then appended into the 'users' div area on the page. When you run this page you should initial see a single line saying "Processing.." for a second then the following result.226 If the call is successful, then we loop over the result and build out a html string of list items "<li>". This html string is then appended into the 'users' div area on the page. When you run this page you should initially see a single line saying "Processing.." for a second then the following result. 227 227 228 228 (Image in progress)
![(please configure the [header_logo] section in trac.ini)](/ModelGlue.com/trac.cgi/chrome/site/your_project_logo.png)