ColdFusion Returns UPPER CASE Struct Variables to Flex 3
Filed under ActionScript , ColdFusion , Flex
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:
<cfset var stItm = StructNew()>
<cfset stItm.upper = "test">
<cfset stItm.lower = "test2">
<cfset arrayAppend(myArray, stItm)>
The above code will return both the struct items in upper case to flex 3. IE (UPPPER = test, LOWER = test2)
<cfset var stItm = StructNew()>
<cfset stItm["UPPER"] = "test">
<cfset stItm["lower"] = "test2">
<cfset arrayAppend(myArray, stItm)>
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 <property-case> tag inside the proper <destination> (default is <destination id="ColdFusion">) and modify the properties within. I have highlighted below the code to modify.
<service id="remoting-service"
class="flex.messaging.services.RemotingService"
messageTypes="flex.messaging.messages.RemotingMessage">
<adapters>
<adapter-definition id="cf-object" class="coldfusion.flash.messaging.ColdFusionAdapter" default="true"/>
<adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter"/>
</adapters>
<default-channels>
<channel ref="my-cfamf-secure" />
<channel ref="my-cfamf"/>
</default-channels>
<destination id="ColdFusion">
<channels>
<channel ref="my-cfamf-secure" />
<channel ref="my-cfamf"/>
</channels>
<properties>
<source>*</source>
<!-- define the resolution rules and access level of the cfc being invoked -->
<access>
<!-- Use the ColdFusion mappings to find CFCs, by default only CFC files under your webroot can be found. -->
<use-mappings>false</use-mappings>
<!-- allow "public and remote" or just "remote" methods to be invoked -->
<method-access-level>remote</method-access-level>
</access>
<property-case>
<!-- cfc property names -->
<force-cfc-lowercase>false</force-cfc-lowercase>
<!-- Query column names -->
<force-query-lowercase>false</force-query-lowercase>
<!-- struct keys -->
<force-struct-lowercase>true</force-struct-lowercase>
</property-case>
</properties>
</destination>
</service>
Hope this helps someone out there. I would like to know how this works or if there are some other little things I should know. ;)
| View count: 809Apr20








