Thanks for taking the time to answer all of my questions...
OK,
I had been originally trying to do this in my main application, but seeing as
that wasn't working, I set up a test environment.
I've created (all in my src folder of my Test Flex project)
Test.mxml
TestClass.as
TestClass.cfc
TestClassGateway.cfc
In my gateway file I generate a struct VO. The function I use is:
<cffunction name="buildStruct" output="false" access="remote">
<cfset var i = 0>
<cfset var obj = structNew() />
<cfset var ret = arrayNew( 1 )>
<cfscript>
while (i lt 100) {
obj['__type__'] = 'TestClass';
obj['firstName'] = "";
obj['lastName'] = "";
obj['address1'] = "";
obj['address2'] = "";
obj['city'] = "";
obj['state'] = "";
obj['zip'] = "";
obj['country'] = "";
obj['email'] = "";
obj['phone'] = "";
obj['fax'] = "";
arrayAppend( ret, duplicate( obj ) );
i = i+1;
}
</cfscript>
<cfreturn ret />
</cffunction>
I use a getAll function to return this newly created VO to my calling AS object
<cffunction name="getAll" output="false" access="remote">
<cfreturn buildStruct() />
</cffunction>
My TestClass.cfc has:
<cfcomponent output="false" alias="TestClass">
<cfproperty name="firstName" type="string" default="" />
<cfproperty name="lastName" type="string" default="" />
<cfproperty name="address1" type="string" default="" />
<cfproperty name="address2" type="string" default="" />
<cfproperty name="city" type="string" default="" />
<cfproperty name="state" type="string" default="" />
<cfproperty name="zip" type="string" default="" />
<cfproperty name="country" type="string" default="" />
<cfproperty name="email" type="string" default="" />
<cfproperty name="phone" type="string" default="" />
<cfproperty name="fax" type="string" default="" />
<cfscript>
this.firstName = "";
this.lastName = "";
this.address1 = "";
this.address2 = "";
this.city = "";
this.state = "";
this.zip = "";
this.country = "";
this.email = "";
this.phone = "";
this.fax = "";
</cfscript>
</cfcomponent>
My TestClass.as has
[RemoteClass(alias="TestClass")]
public class TestClass extends EventDispatcher {
(along with getters/setters and my constructor and function call to the
TestClassGateway).
When the data is returned back to AS from CF, it is still just an array of
generic objects. If I create CF objects and return them, they come back as an
array of TestClass objects. I also noticed that in the list of properties of
the generic objects, __type__ is one of them. If it's being converted, this
shouldn't be there, should it?
>Sorry I guess I wasn't clear, you absolutely can return arrays of typed
>structs and have them converted for you. That's the main point of doing
>this. You can return thousands of objects in arrays, and it is ridiculously
>faster then creating cfcs, you do not need LCDS to do this.
>
>I mentioned the array because in Flex if you don't have an instance of the
>AddressBook object compiled into the app, it will come in as a generic
>object. But if it works when you return arrays of vos that were created with
>CreateObject, then that's not the problem.
>
>Is the AddressBook.cfc in your webroot or is it under some path?
>
>This :
>
>[RemoteClass(alias="AddressBook")]
>
>will only work (with this method) if AddressBook is in your webroot, if you
>use CreateObject it will work without the fully qualified path, but if you
>want to use this typed struct method you have to use the full path.
>
>So if your AddressBook is actually in com.vo.AddressBook then you have to
>use
>
>struct['__type__'] = 'com.vo.AddressBook'
>
>and
>
>[RemoteClass(alias="com.vo.AddressBook")]
>
>Sorry if I am making it sound more complicated then it is, but it basically
>boils down to making sure your __type__ is fully qualified and matches your
>alias.
>
>
>On Feb 19, 2008 5:15 PM, Gareth Arch <[EMAIL PROTECTED]> wrote:
>
>>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:299402
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4