johnbarrett
02/28/2022, 3:06 AMcomponent {
this.name = "myApplication";
this.applicationTimeout = CreateTimeSpan(0, 2, 0, 0); //2 hours
this.datasource = "cfhawaii";
this.sessionManagement = true;
this.sessionTimeout = CreateTimeSpan(0, 0, 30, 0); //30 minutes
this.customTagPaths = [ expandPath('/myAppCustomTags') ];
function onApplicationStart() {
return true;
}
function onSessionStart() {}
// the target page is passed in for reference,
// but you are not required to include it
function onRequestStart( string targetPage ) {}
function onRequest( string targetPage ) {
include arguments.targetPage;
}
function onRequestEnd() {}
function onSessionEnd( struct SessionScope, struct ApplicationScope ) {}
function onApplicationEnd( struct ApplicationScope ) {}
function onError( any Exception, string EventName ) {}
}
danmurphy
02/28/2022, 3:40 AMjohnbarrett
02/28/2022, 3:44 AMAdam Cameron
this.datasource
is an application setting, not a variable. You can use it as a variable within Application.cfc, but it's not then exposed as a variable datasource
elsewhere in your app. If you need an application-wide variable (which is where DSNs are often set), then you'd also need to set application.datasource
in your onApplicationStart
handler.
You are including your requested file in your onRequest
handler, so your entire request will be running in the context of that Application.cfc instance, so you should be able to use this.datasource
, rather than just datasource
. That said... the whole point of setting this.datasource
is so you don't need to specify the datasource every time you need to use it.
---
In my <cfquery> I can't use #datasource# or I get qet blank pageThis is odd behaviour. You should be getting an error along the lines of "`Element datasource is undefined in VARIABLES`". That you're getting a blank page indicates something ain't configured right / well..? --- From a tidiness POV, none of those other event handlers in your Application.cfc are doing anything. There's no point in having them in there.
Mark Takata (Adobe)
02/28/2022, 5:53 PMMatt Jones
02/28/2022, 6:19 PMwriteDump(exception);
Adam Cameron
Adam Cameron
johnbarrett
03/01/2022, 12:16 AMjohnbarrett
03/01/2022, 12:20 AMjohnbarrett
03/01/2022, 12:23 AM