Rob Gonda's Blog

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.

TrackBacks
There are no trackbacks for this entry.

Trackback URL for this entry:
http://www.robgonda.com/blog/trackback.cfm?C6803F76-3048-7431-E483E3DFF63CACD3

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
This blog is running version 5.9.003. Contact Blog Owner