ColdFusion News Desk
ajaxCFC - Addressing Html Code in Application.cfc
I just got hit with an email informing me that ajaxCFC will break when application.cfc adds code onRequest(start|end).
Jan. 16, 2006 12:00 PM
Digg This!
ajaxCFC: addressing html code in application.cfc
I just got hit with an email informing me that ajaxCFC will break when application.cfc adds code onRequest(start|end). I modified the framework to reset the content before the JavaScript response, and abort it at the end of the asynchronous call. I am not quite happy with the abort though, so if someone has a better solution to eliminate all code generated by onRequestEnd please comment it here. I tried to open a JS comment segment, but then it results on unfinished comment; setting enable cfoutput only will only work if the code in application doesn't use cfoutput; cfsilent needs an ending tag.
The abort works for most of the cases; the AJAX request will always work, but if you had some custom code in your onRequestEnd, such as logging, it will not be executed.
Note on application.cfc: as a general rule, try to avoid using application.cfm/cfc for html rendering. It is advisable to separate your logic from the presentation layer. Application.cfc, just like any other component, is encapsulated and parameterized, and should not display html. If you successfully separate your logic from your views, you will be able to use the same architecture for presentation layers such as html, ajax, flash, flex, laslo, or mobile devices.
About Rob GondaRob Gonda is the CTO for iChameleon Group and Contributing Editor to AJAXWorld Magazine. He is an Advanced Certified Coldfusion Developer, member of the Adobe Community Experts, frequent contributor to the CFDJ and ADJ, frequent speaker at IT and developer conferences nationwide, co-author of Real-World Ajax Book, author of ajaxCFC, holds a BS in computer science and engineering, an MBA with a specialization in entrepreneurship, and he specializes in Rich Internet Applications and object-oriented architecture. You can reach him at rob[at]robgonda[dot]com and read his blog is at http://www.robgonda.com