Always use output="false" in your application.cfc ....

... if you are using any of the new cf8 ajax stuff in your application.

The very first thing in my application is a simple login form and a simple ajax call to validate the user. After I added the application.cfc template it would not work. The call to the cfc would return nothing at all.

So I found various tips about how you should add some code so that onRequest don't mess up your cfc calls. No luck! Then I tried removing onRequest, onRequestStart and even onRequestEnd. Still no luck.

So I Googled and in the end found a blog post that mentions similar problems if you have a application.cfm file that has any html output. This got me thinking, and I quickly put output="false" in my cfcomponent tag :

<cfcomponent output="false">

Why did I not have it there in the first place you might ask. Well, I copied the application.cfc template from the CF7 live docs.

Another lesson learned.

Comments
Using the output="false" attribute is great! Once I learned about it I always use it on my cfc's. One thing to remember, though, is that even though you put it on a cfc the functions will still be able to generate output unless there is also an output="false" on the function tag itself. My test to double check was:

<cfcomponent output="false">
in component
   <cffunction name="test">
   in function
   </cffunction>
</cfcomponent>

The only thing that printed was 'in function'.
# Posted By Robert Gatti | 3/15/08 12:41 AM
Did you get this to work if you are using the OnRequest method in your Application.cfc template? I'm running into the same issue. Putting output=false on the main component declaration didn't help. Putting it on both the main declaration and the onRequest method simply prevents the onRequest method from displaying the page content.

Thanks.
# Posted By James, F.E. | 3/17/08 7:58 AM
I deleted the onRequest method, as in my research I found that it could be the source to problems when using cfc's.

These links could be helpfull:

http://corfield.org/blog/index.cfm/do/blog.entry/e...

http://www.cfcode.net/blog/post.cfm/important-gotc...
# Posted By Trond Ulseth | 3/17/08 9:08 AM