Shaun Mccran

My digital playground

01
J
U
L
2008

ColdFusion - Flex remoting struct() case sensitivity

One of the more frequent data Objects that I pass from CF to Flex is the structure. I recently stumbled upon a case sensitivity issue in flex, that can be solved in CF with a slight change in code.

Take the code below. Its perfectly valid cfml. It will return this:

view plain print about
1<cfscript>
2 var date = dateFormat(Now(), "dd-mm-yyyy");        
3 var returnStruct = structNew();
4 returnStruct.date = date;
5
</cfscript>

Notice how it is all UPPERCASE! Flex doesn't like this at all...

So if we change the last line below like this.

view plain print about
1<cfscript>
2 var date = dateFormat(Now(), "dd-mm-yyyy");        
3 var returnStruct = structNew();
4 returnStruct["date"] = date;
5
</cfscript>

It will return the same structure, but now in lower case!

Who'd of thunk that such a simple coding change can alter the sensitivity of the names.

Also I've read elsewhere that you can edit the 'Services-Config.xml' file in your flex root (on server).

view plain print about
1<property-case>
2<!-- cfc property names -->
3<force-cfc-lowercase>true</force-cfc-lowercase>
4<!-- Query column names -->
5<force-query-lowercase>true</force-query-lowercase>
6<!-- struct keys -->
7<force-struct-lowercase>true</force-struct-lowercase>
8</property-case>

Looks like you can globally force the case to lower. I haven't tried this, as I don't really want such a sweeping change. I'd rather amend my coding standards to encapsulate the differing structure code.

Also remember that changes to this file requires a service stop-start.

TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Stuart John Michael's Gravatar Thesis writing must always be done in such a manner that the thesis should be reliable and valid in nature. The http://www.superiorepapers.com/ measures of validity and reliability should be accurately made by the researcher.
# Posted By Stuart John Michael | 24/11/2015 03:14
Back to top