The amazing adventures of Doug Hughes

I usually try to remain fairly positive on this blog and not be outright negative about, well, anything. But this time I simply don’t have any way to look positively on my most despised feature of ColdFusion. To put it simply, I hate how ColdFusion shows a JavaScript alert every time there’s a problem with anything related to cfajax.

Right now, I’m working on an absolutely insane HTML form. When done it will probably have multi-hundreds of fields. (Before anyone blasts me on this, there are business processes which require such a complex form and processes are in place to make it less cumbersome.) This form has a lot of fields which are bound to other fields. Furthermore, this is a Model-Glue application and if you run into a ColdFusion error an error event handler is displayed, not an inline error message as with traditional ColdFusion development. This means that every time I get a ColdFusion error all my bindings fail and I have to click through a metric ton of alert messages.

And, to make matters worse, I’m on a Mac where alert messages slide in from the top of the browser so they take longer. Today this chaffed me for the last time and I’ve decided to switch to PHP! (Just Kidding!!) Actually, I tracked down where CF’s JavaScript was showing these bloody alert messages. This is within a function called handleError within cfajax.js. In this function the code looks to see if you’re logging errors (via that cf ajax logging interface), or if there’s a global error handler, and, failing that, it shows an alert message. I tracked down the code on the global error handler and it turns out that there’s an undocumented feature of the ColdFusion Ajax features that lets you handle errors your own way. Once I figured that out, redirecting the error messages to the FireBug console became extremely easy with this small chunk of code:

// this overrides the default CF error handling alert message!
ColdFusion.setGlobalErrorHandler(function (error) {
    if (typeof console != & quot; undefined & quot;) {
    } else {

This code should be compatible with all browser configurations as well in that if the console does not exist the alert messages will be shown instead.

Comments on: "Bind Error Alert Messages: My Most Despised ColdFusion Feature (And a Solution!)" (7)

  1. Put in the blog title that you have a solution in addition to your rant? FREDTERP


  2. Doug Hughes said:

    @FREDTERP – Good call! It’s been done.


  3. Doug Hughes said:

    @Sam – Thanks for pointing that out. I had no idea!


  4. @Doug: No worries.

    Another goodie in the CF JavaScript library that is easy to overlook is:

    ColdFusion.getElementValue(elementId [, formId, attributeName])

    which returns the value (or text based on the third argument) of any element.


  5. Thanks, it is very useful, you make my day!


  6. Richard said:

    Thanks a ton!! This was the solution I was looking for. You get the up arrow on Google for this one.


Comments are closed.

Tag Cloud

%d bloggers like this: