If you have ever tried to return struct to Flex 3 from ColdFusion you may have run into this problem. If you use dot (.) notation to define your struct variable, the variable will get passed in UPPER CASE. This causes problems because Flex 3 and actionscript are case sensitive. Not knowing this little fact may cause you to bang your head on some walls.
Here is an example and a couple solutions:
{tag}cfset var myArray = ArrayNew(1){tag}
{tag}cfset var stItm = StructNew(){tag}
{tag}cfset stItm.upper = "test"{tag}
{tag}cfset stItm.lower = "test2"{tag}
{tag}cfset arrayAppend(myArray, stItm){tag}
The above code will return both the struct items in upper case to flex 3. IE (UPPPER = test, LOWER = test2)
{tag}cfset var myArray = ArrayNew(1){tag}
{tag}cfset var stItm = StructNew(){tag}
{tag}cfset stItm["UPPER"] = "test"{tag}
{tag}cfset stItm["lower"] = "test2"{tag}
{tag}cfset arrayAppend(myArray, stItm){tag}
Using the brackets "[ ]" to define your struct variables will return the variables to flex in the proper case. IE (UPPPER = test, lower= test2 ).
If you must use dot (.) notation for what ever reason you are still in luck with a little motification of the remoting-config.xml which is normally located by default here (C:\ColdFusion8\wwwroot\WEB-INF\flex). Inside the file all you need to do is locate the {tag}property-case{tag} tag inside the proper {tag}destination{tag} (default is {tag}destination id="ColdFusion"{tag}) and modify the properties within. I have highlighted below the code to modify.
Hope this helps someone out there.
No comments:
Post a Comment