Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to create an unscoped global in application.cfc?

I'm migrating an old app that uses application.cfm to use an application.cfc. The CFM sets a few globals such as

<cfset dsn = "myDSN">

I've tried putting that line of code in onApplicationStart, onRequestStart, etc. but trying to print that value out in a test page results in an error. Setting a value in the application scope (e.g. application.dsn) works fine of course but I'm under a tight deadline and can't rock the boat by doing a site-wide search and replace for each global.

I know putting these in scopes is the right thing to do but, for the time being, is there any way to switch to using Application.CFC but still create unscoped global variables?

like image 592
DaveBurns Avatar asked Jun 09 '10 14:06

DaveBurns


People also ask

What is application CFC in ColdFusion?

Application event handlers are CFC methods that ColdFusion automatically executes when specific events occur during the lifetime of an application: application start and end, session start and end, request start, execution, and end, and exceptions.

Which of the following pages executes first when a ColdFusion application runs?

ColdFusion always processes onRequestStart at the start of the request. If you implement an onRequest method, ColdFusion processes it; otherwise, it processes the requested page. If you implement an onRequest method, explicitly call the requested page in your onRequest method.


1 Answers

Try putting it inside onRequest() instead of onRequestStart().

like image 91
Ken Redler Avatar answered Oct 13 '22 00:10

Ken Redler