Legitimate use for Evaluate()? Do Not Want!

I hate Evaluate(). I hate it like I hate mornings without coffee. I hate it like getting Visual Studio's Debugger to work. I hate Evaluate(), and thats why I'm sad to say that I think I've found a case where I can't use any of my standard tricks to avoid using Evaluate(), and have to give the ugly beast its moment of glory.

 

Java i18n: I throw in the towel

I've been trying to get Java's ResourceBundle object working for ColdFusion based i18n working off and on for months now, and finally today I bit the bullet and gave up. If you're messing around with ResourceBundle trying to figure out why ColdFusion refuses to find your .properties file, I recommend that you stop, take a deep breath, and check out the following: rbJava/JavaRB CFC.

Basically, it is a wrapper for the technique described in this ColdFusion Developer's Journal article, that uses FileInputStream to read in an individual properties file. It seems that no one's found a way to get Java to pick the right file for you in ColdFusion.

That link offers three different underlying techniques for localization; I went with the coreJava version, but depending on your needs you might want to choose something else. The coreJava implementation gave me more than enough options, it worked out of the box, and I got it working with new keys and some new wrapping logic in 30 minutes.

 

Why IIF() Should be Avoided

I was recently reviewing some code from one of my client projects and saw that the previous developer had liked to use IIF() functions to handle the conditional switching of things like button labels. I idly quipped on Twitter that Every time you execute IIF() an angel loses its wings. A few minutes later a request for some explanation came in on Facebook: Why's that? I like IIF(). Here is why you should avoid IIF().

 

Utility Function: ImageBlurMore()

OK, so up until now you probably can guess that the functionality I'm working on has something to do with drawing or moving a shape since I've posted math rounding functions and functions dealing with geometric positioning. Lets throw you a curve-ball: I also need the following function. What happens when ImageBlur(image, 10) just isn't enough? Well you're going to need to blur the image more!

 

Utility Functions: Geometry Functions

Today we've got a double header of functions dealing with Geometry. As I said in my last post, I've been spurred into action by a user's question, and in order to solve his problem, I'm going to need to be able to calculate some relatively simple geometry. Click "more" to see how to convert Degrees to Radians and how to calculate the position of a point based on a starting location, angle, and distance.

 

Utility Function: RoundToClosest()

Its been a while! I got an email from a reader who wanted some help with a bit of image manipulation that has roused me back into CF coding! The particular bit of functionality he wants is rather complex, and so its been forcing me to make a bunch of utility functions to piece it together. First thing I ran into: rounding a number in CF is a little tricky. If you want to round to 2 decimal places, you should multiply the number by 100, call Round() and then divide by 100 again. What a waste. Luckily a little trickery with NumberFormat() can get us what we want.

 

More Entries

Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me on LinkedIn.