Blog

Introspecting Application.cfc

August 12, 2009 · 7 Comment s

I've gotten this question a bunch of times. How do you get information about what's enabled in your application scope? How do I know if ORM is enabled, or what the datasource is?

Pretty easy - Instantiate the Application scope, and then get that information from the This scope.

<cfset test= new Application() />
<cfdump var="#test.ormenabled#">


Tags: ColdFusion

7 response s so far ↓

  • 1 Ryan Vikander // Aug 12, 2009 at 2:35 PM

    Maybe I am wrong, but can't you just <cfdump var="#Application#">?
  • 2 Ryan Vikander // Aug 12, 2009 at 2:37 PM

    Nevermind, after testing that doesn't work.
  • 3 Billy Cravens // Aug 12, 2009 at 6:34 PM

    Since you have to create an object, I'd think you could
    <cfset test = new Application()>
    <cfdump var="#test#">
  • 4 Ben Nadel // Aug 19, 2009 at 9:14 AM

    Nice! I never thought of actually creating a new instance of the CFC. Very cool idea! I always used some hacky approach like dumping out the secret properties of the application scope. Your way is much better!
  • 5 Ben Nadel // Aug 19, 2009 at 1:33 PM

    Thanks Terry - I was enjoying this post again at lunch :)
  • 6 Terrence Ryan // Aug 19, 2009 at 1:35 PM

    Thanks, Ben. I'm glad you liked it. It was one of those "It's so simple it can't work" moments.
  • 7 joe banken // Sep 19, 2009 at 11:07 AM

    Thats pretty cool man, I also did not know you could do new Application(). Nice find.

Leave a Comment