Twitter: raymondcamden


Address: Lafayette, LA, USA

Warning About Application Events

02-07-2005 17,662 views ColdFusion

Ok, so I love Application Events and the new Application.cfc. I really, really love it. That being said, there are a few "issues" you should be aware of when using it:

onError: When using the onError method, every single <cflocation> call will fire the event. Kind of a silly bug, but it didn't get found till too late. Christian Cantrell came up with a nice work around to place inside your onError:

<cfif arguments.exception.rootCause eq "coldfusion.runtime.AbortException">
<cfreturn/>
</cfif>

If you don't have this, your error handling will fire when you don't really want it to.

onRequest: This is covered in the docs - but I know people are going to miss it. If you use onRequest, you cannot use Flash Remoting or Web Services. This is kinda silly too and I hope it gets fixed soon. I get the reasons behind it, but it should still be corrected I think. Sean came up with a nice workaround for it. If your CFCs are in a subfolder, add a Application.cfc in and use code like so:

<cfcomponent name="Application" extends="test.Application">
<cfset structDelete(variables,"onRequest")/>
<cfset structDelete(this,"onRequest")/>
</cfcomponent>