Ok, having some struggles here with ColdFusion CFCs, related AS VOs,
and remoteobject.
Say I have a CFC called Customer.cfc which is bean styled. It has a
property Addresses which is a array of Address.cfc also bean styled.
Similarly I have ActionScript VOs setup and registered to map to the
CFCs. Ok, I build a Flex app that retrieves a Customer object. It
gets mapped over to AS ok, I can see the array of Address objects and
see they are typed correctly. Now I call a method via RemoteObject
called save() passing the Customer object to this method. Bomb! When
the AS array of objects is passed to CF it loses its type. Below I
have some code example of what things look like.
Thoughts?
Customer.cfc
<cfcomponent>
<cfproperty name="customerId" type="numeric" default="0" />
<cfproperty name="addresses" type="address[]" />
<cfscript>
variables.customerId= 0;
variables.address = ArrayNew(1);
</cfscript>
<cffunction name="getCustomerId" output="false" access="public"
returntype="numeric">
<cfreturn variables.customerId>
</cffunction>
<cffunction name="setCustomerId" output="false" access="public"
returntype="void">
<cfargument name="val" required="true">
<cfset variables.customerId = arguments.val>
</cffunction>
<cffunction name="getAddress" output="false" access="public"
returntype="address[]">
<cfreturn variables.address >
</cffunction>
<cffunction name="setAddress" output="false" access="public"
returntype="void">
<cfargument name="val" required="true" type="address[]" >
<cfset variables.address = arguments.val>
</cffunction>
</cfcomponent>
address.cfc
<cfcomponent >
<cfproperty name="addressId" type="numeric" default="0">
<cfproperty name="address1" type="string" default="">
<cfproperty name="city" type="string" default="">
<cfproperty name="state" type="string" default="">
<cfproperty name="zip" type="string" default="">
<cfscript>
//Initialize the CFC with the default properties values.
variables.addressId = 0;
variables.address1 = "";
variables.city = "";
variables.state = "";
variables.zip = "";
</cfscript>
<cffunction name="init" output="false" returntype="address">
<cfreturn this>
</cffunction>
<cffunction name="getAddressId" output="false" access="public"
returntype="any">
<cfreturn variables.AddressId>
</cffunction>
<cffunction name="setAddressId" output="false" access="public"
returntype="void">
<cfargument name="val" required="true">
<cfif (IsNumeric(arguments.val)) OR (arguments.val EQ "")>
<cfset variables.AddressId = arguments.val>
<cfelse>
<cfthrow message="'#arguments.val#' is not a valid
numeric"/>
</cfif>
</cffunction>
<cffunction name="getAddress1" output="false" access="public"
returntype="any">
<cfreturn variables.Address1>
</cffunction>
<cffunction name="setAddress1" output="false" access="public"
returntype="void">
<cfargument name="val" required="true">
<cfset variables.Address1 = arguments.val>
</cffunction>
<cffunction name="getCity" output="false" access="public"
returntype="any">
<cfreturn variables.City>
</cffunction>
<cffunction name="setCity" output="false" access="public"
returntype="void">
<cfargument name="val" required="true">
<cfset variables.City = arguments.val>
</cffunction>
<cffunction name="getState" output="false" access="public"
returntype="any">
<cfreturn variables.State>
</cffunction>
<cffunction name="setState" output="false" access="public"
returntype="void">
<cfargument name="val" required="true">
<cfset variables.State = arguments.val>
</cffunction>
<cffunction name="getZip" output="false" access="public"
returntype="any">
<cfreturn variables.Zip>
</cffunction>
<cffunction name="setZip" output="false" access="public"
returntype="void">
<cfargument name="val" required="true">
<cfset variables.Zip = arguments.val>
</cffunction>
</cfcomponent>
customer.as
package customer
{
[RemoteClass(alias="customer")]
[Bindable]
public dynamic class customer
{
public var customerId:Number = 0;
public var address:Array;
public function custumer()
{
}
}
}
address.as
package address
{
[RemoteClass(alias="address")]
[Bindable]
public dynamic class address
{
public var addressId:Number = 0;
public var address1:String = "";
public var city:String = "";
public var state:String = "";
public var zip:String = "";
public function address()
{
}
}
}
--
Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it?
------------------------ Yahoo! Groups Sponsor --------------------~-->
Great things are happening at Yahoo! Groups. See the new email design.
http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~->
--
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
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/