Using CFApplication Inside Of ColdFusion's Application.cfc

Posted May 29, 2007 at 8:43 AM

Tags: ColdFusion

Last week, I gave a Nylon Technology presentation on ColdFusion's Application.cfc component. While giving the presentation, it occurred to me - if Application.cfc is a component just like any other and it really just defines a ColdFusion application, I wonder what would happen if you use ColdFusion's CFApplication tag inside of the Application.cfc. To test this, I set up a very simple Application.cfc:

 Launch code in new window » Download code as text file »

  • <cfcomponent>
  •  
  • <!--- Define application. --->
  • <cfapplication
  • name="CFApp In AppCFC"
  • />
  •  
  • <!--- Define page settings. --->
  • <cfsetting
  • requesttimeout="5"
  • />
  •  
  •  
  • <!---
  • Set an application variable just to be
  • able to echo something out in our CFDump.
  • --->
  • <cfset APPLICATION.CFAppTest = "Interesting" />
  •  
  • </cfcomponent>

The Application.cfc does not contain anything Application.cfc-related; it acts merely as a container for the CFApplication tag. It then uses a standard CFSetting tag and attempts to set an APPLICATION variable that we would echo in a later CFDump.

Then, in index page, all I am doing is CFDumping out the APPLICATION scope:

 Launch code in new window » Download code as text file »

  • <cfdump
  • var="#APPLICATION#"
  • label="CFApplication Test"
  • top="10"
  • />

Running this page throws the following ColdFusion error:

5 >= 0

Not one of ColdFusion's most intuitive errors (something similar to what is seen when using CFQueryParam and cached database structures), but since I was testing something very specific, I knew what caused it. Apparently, you cannot use the ColdFusion's old CFApplication inside of its new Application.cfc component.

Download Code Snippet ZIP File

Comments (2)  |  Post Comment  |  Ask Ben  |  Permalink  |  Print Page




Adobe ColdFusion 8.0.1 Update - Helping Programmers To Be Signifanctly Less Girlie - Download ColdFusion 8 Update 8.0.1 Now.

Reader Comments

Which is probably a good thing. ;)

I wonder what happens if you try the same code inside onRequestStart?

Posted by Raymond Camden on May 29, 2007 at 8:56 AM


I was just wondering the same thing so I tried it out. Moving the code to the OnRequestStart function works just fine.

Posted by Joshua Cyr on Apr 14, 2008 at 4:09 PM


Post Comment  |  Ask Ben


Home   |   Web Log   |   ColdFusion   |   Projects   |   Resume   |   Job Form   |   Search   |   Contact
Epicenter Consulting - Custom Software Solutions for Business Evolution HostMySite.com - The Leader In ColdFusion Hosting