How to reinitialize the website in Application.cfm file scope

823 views Asked by At

Maybe the Title seems bit odd, but my question is straight, how can reinitialize the application with Application.cfm, i know how we do in Application.cfc like

<cfscript>
if(structKeyExists(url, 'reinit')) {
    onApplicationStart();
}
</cfscript>

But how in Application.cfm, not sure, please guide

Thanks

2

There are 2 answers

6
Adam Cameron On

Firstly, running onApplicationStart() no more restarts the application than running an onClick() mouse-click event handler causes your mouse button to depress. onApplicationStart() is called as a result of the application starting, not the other way around.

Secondly, Application.cfm has nothing to do with the application lifecycle, it is merely a CFML file that is included at the beginning of every request. it is more closely associated with onRequestStart() than onApplicationStart(): the file is, unfortunately, misnamed. Its counterpart onRequestEnd.cfm demonstrates this.

I presume your requirement here is to re-initialise your application scope, yes? Do you have all your application-scope setting isolated in a specific CFML file, eg: applicationSettings.cfm, and then have logic like this in your Application.cfm:

// Application.cfm
if (!structKeyExists(application, "inited")){
    include "applicationSettings.cfm";
}

(then as a last thing in applicationSettings.cfm set application.inited to true).

If so you simply need to modify your condition to include your URL reinit variable, eg:

if (!structKeyExists(application, "inited") || structKeyExists(URL, "reinit")){
    include "applicationSettings.cfm";
}
0
Mark Gregory On

In OnRequestStart() put something like this:

param name='url.reloadApp' default='no';

if(url.reloadApp == 'yes')
{
    applicationStop();
}