Status/Resolution/Reason: Needs Review//
Reporter/Name(from Bugbase): Jhonatan Rosa Jacinto / Jhonatan Rosa Jacinto (Jhonatan Rosa Jacinto)
Created: 12/30/2014
Components: Language
Versions: 11.0
Failure Type: Enhancement Request
Found In Build/Fixed In Build: CF11_Final /
Priority/Frequency: Trivial / Unknown
Locale/System: English / Windows 8.1
Vote Count: 2
CFPARAM tag is excellent for checking values before using them. However, every time a value do not match the specified criteria of the tag an "Expression exception" is thrown. Although it's OK in some situations, in others it's not. Here is a concrete example:
I had a dashboard page which uses a URL parameter named "year" to filter the data of the charts and lists to match a specified year. In case no year was specified, 2014 was used instead. Then I used <cfparam> tag like so:
<cfparam name="URL.year" default="2015" type="regex" pattern="[0-9]{4}">
But, if an invalid value was passed in this parameter (a 5 digit number or a text string for instance), we should use the default value (2014) to build the dashboard instead of showing an error message. That's why I thought about a boolean atribute like "onErrorUseDefault" which if set to 'true" would not throw an exception and set the URL.year variable to the default value, otherwise the exception would be thrown (the same way that happens today).
That would avoid the use of a <cftry><cfcatch> block to treat this, 'cause it would be solved in just one line:
Instead of this:
<cftry>
<cfparam name="URL.year" default="2014" type="regex" pattern="[0-9]{4}">
<cfcatch type="expression">
<cfset URL.year = 2014>
</cfcatch>
</cftry>
We would use this:
<cfparam name="URL.year" default="2015" type="regex" pattern="[0-9]{4}" onErrorUseDefault="true">
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3915403
External Customer Info:
External Company:
External Customer Name: Jhonatan Rosa Jacinto
External Customer Email:
External Test Config: My Hardware and Environment details: CF 11, Win 8.1, IIS 8.5
Attachments:
Comments: