Adrian,

I made a custom tag called cf_param that does exactly this. If the type of the 
variable does not match, such as your case, the default value is used. You can 
get the custom tag at http://www.cornfeed.com. It is a couple years old, but 
works just fine, as I use it all over the place.

Cedric

>I had a similar idea ages ago except I think that the setting of the var
>should still happen if the type check fails.
>
><cfset myID = "not an ID, a string!">
>
><cfparam name="myID" type="numeric" default="0">
>
><!--- By here myID would be 0 and no error thrown --->
>
>Adrian
>
>P.S. Did you get my last few emails Mike? I sent the files and a follow-up
>email but no reply.
>
>-----Original Message-----
>From: Michael Dinowitz [mailto:[EMAIL PROTECTED]
>Sent: 14 February 2006 20:12
>To: CF-Talk
>Subject: [OT] Future CF Features
>
>
>This is a follow up from another post about what happens when someone
>removes the ?wsdl from a web service CFC. I'd like to have my first request
>be either an admin setting or something else to redirect or choose where to
>go when a .cfc is loaded directly in an url without any passed variables.
>
>The second request deals with CFPARAM with the type attribute set. If this
>fails, an error is thrown. In order to deal with the error, the CFPARAM tag
>has to be within a try/catch. If we know an error may be thrown from this
>tag, why not give the tag the ability to deal with the error.
>My suggestion is to keep the tag as is but add the ability to put a closing
>CFPARAM tag. What will be placed between the start and end CFPARAM tags is
>the code that will be run if there is an error.
><CFPARAM name="id" type="numeric">
>error processing code here to deal with the the id not existing or not being
>numeric
></CFPARAM>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232279
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to