20.11. Passing Named Parameters to ColdFusion Component Methods
Problem
You want to pass named parameters to a ColdFusion Component (CFC) method using Flash Remoting.
Solution
Create an ActionScript object with properties corresponding to the expected CFC method parameters, and pass that object as a single parameter to the CFC method.
Discussion
You can pass named parameters (as opposed to positional parameters) to a CFC method from a Flash movie. To accomplish this, you should pass a single object parameter to the CFC method in which the property names correspond to the names you have given to the parameters in the CFC method. ColdFusion automatically matches up the object’s property values to the CFC method’s parameters with the same names. For example:
<!--- A sample CFC method definition ---> <cffunction name="getCarInfo" access="remote"> <cfargument name="make" type="string"> <cfargument name="model" type="string"> <!--- rest of method body ---> <cffunction> // The corresponding ActionScript snippet . . . // Create an object with properties namedmakeandmodel. params = new Object( ); params.make = "Honda"; params.model = "Accord"; // Call thegetCarInfo( )service function and pass it theparamsobject. myService.getCarInfo(myResponseObject, params);
See Also
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access