|
ColdFusion structures and case sensitivity examples |
Having been using Flex a little more recently I stumbled upon an old issue that I had previously addressed, but it had become second nature, and so I had forgotten about having to learn a workaround in the past. Passing objects from ColdFusion to Flex can be tricky at times, especially as ColdFusion is generally not case sensitive, but Flex is, and this can lead to problems.
I had previously found that how you build your Structure will have an impact the case of the keys. Example one is a Structure built using the traditional dot notation, in a CF 7 and below method:
2 newStruct = structNew();
3 newStruct.starter = "Prawn Salad";
4 newStruct.maincourse = "Roast Chicken";
5 newStruct.desert = "Apple Pie";
6</cfscript>
7
8<cfdump var="#newStruct#" label="Dot notation">
This is the older way of building a Structure, notice how all the keys are uppercase.
The second example is very similar, except that it is using associative array notation, IE brackets to denote the key values, rather than dot notation.
2 newStruct = structNew();
3 newStruct["starter"] = "Prawn Salad";
4 newStruct["maincourse"] = "Roast Chicken";
5 newStruct["desert"] = "Apple Pie";
6</cfscript>
7
8<cfdump var="#newStruct#" label="Struct notation">
Since I originally looked at this ColdFusion 8 (and now 9!) have been released. ColdFusion 8 introduced a new way of creating structures, what casing does this use?
2 starter = "Prawn Salad",
3 maincourse = "Roast Chicken",
4 desert = "Apple Pie"
5} />
6
7<cfdump var="#newStruct#" label="CF 8 method">
It also creates an uppercase structure. I haven't really played around with this method enough to see if there is another way of creating a lowercase structure, so for now I'll be sticking to the older associative array method of creating my structures. That way they are easily transferred as a Flex object.
http://help.adobe.com/en_US/ColdFusion/9.0/Develop...
Also - FYI - struct["key"] is known as 'associative array' notation.
In terms of setting the casing at server level (as per your link) I'm much more of a fan of controlling the code base 'in code', and leaving the server config as vanilla as possible, but that is probably because I've mostly been working on shared hosting platforms, and generally don't have access to things like the 'gateway-config.xml'.