Today in my general work I found a small gotcha about cfparam that wasn’t apparent to me (note that I work in CF under railo, so not sure of the exact implementation in Adobe’s ColdFusion).
Using the following code:
<cfparam name="URL.test" type="boolean" default=false&>
If you loaded a page with this code in it with the URL params looking like: ?test=tr, you would get an error about type mismatch. Now initially this confused me as I thought that an error like this would have been caught and simply the param fixed to the default value. My eventual solution to this is as follows:
<cftry> <cfparam name="URL.test" type="boolean" default=FALSE> <cfcatch type="any"> <cfset URL.test = FALSE> </cfcatch> </cftry>
Hopes this helps someone else as it helped me.