What are some Coldfusion (mx7 and greater) "Gotchas" that I should know about? [duplicate]
Possible Duplicate:
Common programming mistakes for ColdFusion programmer to avoid?
I just spent half the day troubleshooting what is apparently a rather famous gotcha for Coldfusion MX7 and below:
The nested query loop bug:
Where you are required to reference the current_row
of the outer query or else you will only see the first record.
For example:
<cfloop query="outer">
<cfloop query="innner">
<p>#outer.field#</p><!--- this won't work, you'll only get the first row --->
<p>#outer.field[current_row]#</p><!--- you must do this instead --->
</cfloop>
</cfloop&开发者_开发百科gt;
Are there any other ways in which ColdFusion does not work in the obvious way?
- Arrays are pass-by-value!
- case-sensitive for certain ORM related operations / annotations
serializeJSON()
may* mess up your data unexpectedly e.g.'yes' --> 'true'
,1 --> 1.0
<cfdump>
may not be telling you the truthnull
and[empty string]
is the same in a query object- CF9 doesn't support SOAP 1.2 very well, wait til CF10 arrives
- some structs looks like structs, but they're not really struct (e.g.
cfcatch
) - remote methods will get invoked in a new instance of the containing CFC, so don't count on instance variables being ready to be used
var
scope doesn't work as well aslocal.
sometimes when it is defined multiple times in the same function- the ternary operator may evaluate your inline array/structure literal and throw exception if things inside that array/structure is not defined
<cfparam name="foo" default="#bar()#">
,bar()
is always invoked even though foo is defined- might accidentally run into undocumented reserved words: http://www.coldfusionjedi.com/index.cfm/2011/5/9/Interesting-issue-with-reserved-function-names-inside-CFCs
- CF ajax tags and jQuery don't mix
- more here: Common programming mistakes for ColdFusion programmer to avoid?
- and even more here: Things to watch out for in ColdFusion 9 with CF-ORM
精彩评论