|
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:
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.
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).
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.