Skip to main content

ColdFusion 10: onAbort and onRequestEnd behavior

Today, I wrote a post on the new lifecycle method - ‘onAbort’, which can be defined in an Applicaiton.cfc file. It is invoked when the cfabort tag is executed. David Boyer, asked me whether the onRequestEnd method is also invoked on executing the cfabort tag. In CF 9.0.1 it did invoke the onRequestEnd method. See Ben’s post: http://www.bennadel.com/blog/2221-CFAbort-And-OnRequestEnd-Behavior-In-ColdFusion-8-And-ColdFusion-9.htm
Now in CF 10, this behavior has changed. The onRequestEnd method is no longer invoked when cfabort, cflocation or cfcontent tag is executed. The onAbort handler method defined in Application.cfc file would be invoked on executing these tags. Also, the onRequestEnd method would not be invoked even if the abort handler(onAbort) is not defined in Application.cfc.

Comments

  1. I'm pleased to hear that the abort / onRequestEnd behaviour was rolled back :) 

    What's the use case for firing the onAbort even handler when using cflocation or cfcontent though? The intent of the cflocation and cfcontent tags are nothing like doing an abort, IMO, so firing the same event handler for those tags / functions seems strange. 

    Even if the documentation is very clear about when this method is fired, I think it'll catch a lot of developers out because it's probably not what you'd expect to happen. This is why the whole abort / onRequestEnd things was so confusing in the first place!

    ReplyDelete
  2. When cflocation or cfcontent tag is used, the current request is stopped and hence the onAbort handler is invoked. In CF9, it invoked the onRequestEnd method in both the cases. Now such requests are handled through onAbort handler.

    ReplyDelete
  3. My question then, in concrete terms I guess, is *why* does onAbort fire when cflocation or cfcontent is used?

    The documentation says: "Runs when you execute the tag cfabort."
    http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSe61e35da8d318518-2bee337913585ea6004-8000.html 

    That seems perfectly fine if the documentation is accurate, but you're saying it will also run after cflocation or cfcontent...

    The documentation also says onAbort is only passed 1 argument, "targetPage". How can I use that to tell if a cfabort was executed, vs a cflocation or cfcontent? If I had some code that I wanted to handle cfabort's with, it would also be run every time a cflocation or cfcontent was executed - but I might not want that :)

    ReplyDelete
  4. w.r.t the documentation, I'll ask the doc team to update it. Log a doc bug for this.

    As of now, there is no way to determine whether the onAbort method was invoked for cfbort\cflocation\cfcontent. But, that was the same with onRequestEnd as well. However, I do see that, this information could come handy while debugging applications. Please log an ER for this, we will evaluate it.

    The reason why onAbort is invoked for cflocation and cfcontent is that the request terminates when one these tags is executed. Previously it was used to invoke onRequestEnd and now it is onAbort method. If the request would have completed gracefully then the onRequestEnd method would be invoked. This is not the case with cflocation or cfcontent and hence the change. I hope it makes sense now.

    ReplyDelete

Post a Comment

Popular posts from this blog

Custom validation messages for HTML5 Input elements using the constraint validation API

HTML5 has introduced several input types such as EMAIL, URL, RANGE, SEARCH, DATE, TIME, etc,. Most of the modern browsers have implemented them and are ready to be used in a HTML document. Another exciting feature introduced in HTML5 is the form validation. Instead of writing JavaScript to validate users input, browsers can now validate it and show an appropriate message if the validation fails. The validation message is shown in line with the field for which the validation has failed. The default error message is shown when the validation fails. In this post I'll explain how these error messages can be changed.

De-obfuscating javascript code in Chrome Developer Tools

I had blogged about JavaScript debugging with Chrome Developer Tools some time back, wherein I have explained how these developer tools can help in debugging javascript code. Today Google Chrome 12 was released and my Chrome browser was updated to this version. As with every release, there have been some improvements made on performance, usability etc,. One feature that stood out for me is the ability to De-obfuscate the javascript code.

What is Minification?

Minification is the process of removing unnecessary characters such as white spaces, comments, new lines from the source code. These otherwise would be added to make the code more readable. Minifying the source code helps in reducing the file size and thereby reducing the time taken to download the file. This is the reason why most of the popular javascript libraries such as jQuery are minified. A minified jQuery file is of 31 KB in size where as an uncompressed one is about 229 KB. Unfortunately, debugging minified javascript file…

Adding beforeRender and afterRender functions to a Backbone View

I was working on a Backbone application that updated the DOM when a response was received from the server. In a Backbone View, the initialize method would perform some operations and then call the render method to update the view. This worked fine, however there was scenario where in I wanted to perform some tasks before and after rendering the view. This can be considered as firing an event before and after the function had completed its execution. I found a very simple way to do this with Underscore's wrap method.