Jul 7 2010

Flex and ColdFusion Objects

Posted by Steve Onnis at 11:17 AM
1 comments
- Categories: Coldfusion | Coldfusion Server | Flex

Recently ran into something very strange. I was returning a structure to Flex from a ColdFusion Component and FLEX was receiving the structure keys as all UPPERCASE.

Take the following component.

<cfcomponent>
 <cffunction name="helloWorld" access="remote">
  <cfset var result = structNew() />
  <cfset result.msg = "Hello World!" />
  <cfreturn result />
 </cffunction>
</cfcomponent>

When called from Flex, the result will come back as

result.MSG

I guess ColdFusion doesn't see the case being used in the struct.key assinment.  If you want to retain the case of your structure keys you need to assign them like this..

<cfcomponent>
 <cffunction name="helloWorld" access="remote">
  <cfset var result = structNew() />
  <cfset result["msg"] = "Hello World!" />
  <cfreturn result />
 </cffunction>
</cfcomponent>

Creating your structures this way will retain the case of your keys and Flex will receive them in the way you have named them.

Comments

John Gag

John Gag wrote on 07/23/10 8:28 AM

You can fix that in your remoting-config.xml. Here is a post about it.

http://cftips.net/post.cfm/coldfusion-returns-upper-case-struct-variables-to-flex-3

Write your comment



(it will not be displayed)



Leave this field empty: