Here is an example of how to use the RemoteClass metadata in Flex to map Actionscript objects that map directly onto ColdFusion Component that is found on a remote server. The data then can be converted to an Actionscript class with the appropriate properties and referenced in another actionscript class or MXML. My Workspace is under wwwroot/
;
package vo
{
/**
* @private
* What we need to do is map on this actionscript file
* the coldufusion component, this is done by using the Remote
* Class Metadata tag. so [RemoteClass(alias="from(wwwroot Folder).path.to.coldFusionCFC")]
* Everything has to match exactly between the variables declared here and the coldFusion arguments
* that will be declared in the CFC file otherwise it will not work at all. ALso we want this class to be
* Bindable so we can show some information to know that it works
*/
[RemoteClass(alias="RemoteClassExample.src.cfc.cfcVO")]
[Bindable]
public class ColdFusionFlexVO
{
/**
* @private
* What we will be creating are simple variables to
* prove the point, this can be used for a registration form for example.
* Make Sure when you write in the Coldfusion component you use the same
* exact name, case does matter.
* Now Go to the cfcVO.cfc file under cfc
*/
public var firstName:String;
public var lastName:String;
public var emailAddress:String;
public var password:String;
public function ColdFusionFlexVO()
{
}
public function toString():String
{
var result:String= " ";
result += "First Name : "+ firstName +"\n" +
"Last Name : " + lastName + "\n" +
"Email Address : " + emailAddress +"\n" +
"Passwrod : " + password;
return result;
}
}
}

One Response for "Understanding the RemoteClass Metadata and its use in Flex and ColdFusion"
Excellent – My question is, what if your 'returnVOClassObject' component returned 'void' and merely populated itself – and cfreturn'd nothing? Is there a way in flex to be able to declare your object (which exists mapping to a cfc like you have) but merely call a 'read(obj)' on the obj (object) through the remoteObject call – and have that object be fully populated?? I'm getting 'null' in the event.result value – and the object I passed into it is not getting populated.
Thanks
Leave a reply