ColdFusion Struct to Flex Untyped Object Gotcha
Flex and ColdFusion work great together...most of the time. Between the two application frameworks data transformation works really well. For instance, when you pass a ColdFusion query object to Flex, Flex sees it as an ArrayCollection. If you pass an Flex ArrayCollection, ColdFusion automatically interprets it as a ColdFusion query object.
This works great in almost all cases. Something to watch out for when sending ColdFusion structs to Flex is that if you use the "dot-notation" of defining the keys, then in Flex when referencing the keys, the key name must in all caps.
myStruct.firstName = "Kyle";
// Flex trace(myCFStruct.FIRSTNAME);
On the other hand, if you use bracket notation the case follows that of what is inside the quotations.
myStruct["FirstName"] = "Kyle";
// Flex trace(myCFStruct.FirstName);
http://www.kylehayes.info/blog/trackback.cfm?8D644998-1143-DBC8-4BAC469EEB743D89



<force-struct-lowercase>true</force-struct-lowercase>
block of services-config.xml file to force CF to pass struct keys in lowercasce.
How do you use this Coldfusion query object on the coldfusion side?
Thanks
<table>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
<cfoutput query="myQueryFromFlex">
<tr>
<td>#myQueryFromFlex.name#</td>
<td>#myQueryFromFlex.email#</td>
</tr>
</cfoutput>
</table>
var variables:URLVariables = new URLVariables();
variables.QueryFromFlex = ACprosResult; // ACprosResult = Flex ArrayCollection
//Setup a new request and sending the data through a post
var u:URLRequest = new URLRequest("http://mywebsite.com/displayFlexQuery.cfm");
u.data = variables;
u.method = URLRequestMethod.POST;
//Navigate to the displayFlexQuery.cfm
navigateToURL(u,"_blank");
When I display the content of the Flex query, I have
//Alert.show(ObjectUtil.toString(ACprosResult));
(mx.collections::ArrayCollection)#0
filterFunction = (null)
length = 1
list = (mx.collections::ArrayList)#1
length = 1
source = (Array)#2
[0] (Object)#3
FIRST_NAME = "John"
mx_internal_uid = "776493BC-342A-5F09-1ABA-042655F5D74"
LAST_NAME = "Smith"
uid = "BC170492-EAA0-57S1-1731-0426624F18B7"
sort = (null)
source = (Array)#2
On displayFlexQuery.cfm file, I have:
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr>
<cfoutput query="QueryFromFlex">
<tr>
<td>#QueryFromFlex.FIRST_NAME#</td>
<td>#QueryFromFlex.LAST_NAME#</td>
</tr>
</cfoutput>
</table>
Coldfusion throw this error:
The value of the attribute query, which is currently "[object Object]", is invalid.
Any ideas?
Thanks
to get an array created in my cfc to populate a
lineChart. The problem I am having is flex
does not recognize the data type. I have tried
array and struct. The data is an array with
structure. I have posted the code to actionscript.orf
http://www.actionscript.org/forums/showthread.php3...
any sugestions as to how to make this work or
I am doing wrong would be great
Try replacing in your result text:
ArrayCollection(e.result);
with
ArrayCollection(e.result as Array);
[Bindable]
public var dp:ArrayCollection = expenses;
[Bindable]
public var dp:ArrayCollection;