Skip to content

Instantly share code, notes, and snippets.

@rip747
Created February 18, 2010 18:00
Show Gist options
  • Save rip747/307896 to your computer and use it in GitHub Desktop.
Save rip747/307896 to your computer and use it in GitHub Desktop.
skeleton application.cfc file for cf8
<cfcomponent output="false">
<!--- Application name, should be unique --->
<cfset this.name = Hash(GetDirectoryFromPath(GetBaseTemplatePath()))>
<!--- How long application vars persist --->
<cfset this.applicationTimeout = createTimeSpan(0,2,0,0)>
<!--- define custom coldfusion mappings. Keys are mapping names, values are full paths --->
<cfset this.mappings = structNew()>
<!--- define a list of custom tag paths. --->
<cfset this.customtagpaths = "">
<!--- Should we even use sessions? --->
<cfset this.sessionManagement = true>
<!--- How long do session vars persist? --->
<cfset this.sessionTimeout = createTimeSpan(0,0,20,0)>
<!--- Where should cflogin stuff persist --->
<cfset this.loginStorage = "session">
<!--- Should client vars be enabled? --->
<cfset this.clientManagement = false>
<!--- Should we set cookies on the browser? --->
<cfset this.setClientCookies = false>
<!--- Where should we store them, if enable? (cookie|registry|datasource) --->
<cfset this.clientStorage = "cookie">
<!--- should cookies be domain specific, ie, *.foo.com or www.foo.com --->
<cfset this.setDomainCookies = false>
<!--- should we try to block 'bad' input from users --->
<cfset this.scriptProtect = "none">
<!--- should we secure our JSON calls? --->
<cfset this.secureJSON = false>
<!--- Should we use a prefix in front of JSON strings? --->
<cfset this.secureJSONPrefix = "">
<!--- Used to help CF work with missing files and dir indexes --->
<cfset this.welcomeFileList = "">
<!--- Run when application starts up --->
<cffunction name="onApplicationStart" returnType="boolean" output="false">
<cfreturn true>
</cffunction>
<!--- Run when application stops --->
<cffunction name="onApplicationEnd" returnType="void" output="false">
<cfargument name="applicationScope" required="true">
</cffunction>
<!--- Run before the request is processed --->
<cffunction name="onRequestStart" returnType="boolean" output="false">
<cfargument name="thePage" type="string" required="true">
<cfreturn true>
</cffunction>
<!--- Runs before request as well, after onRequestStart --->
<!---
WARNING!!!!! THE USE OF THIS METHOD WILL BREAK FLASH REMOTING, WEB SERVICES, AND AJAX CALLS.
DO NOT USE THIS METHOD UNLESS YOU KNOW THIS AND KNOW HOW TO WORK AROUND IT!
EXAMPLE: http://www.coldfusionjedi.com/index.cfm?mode=entry&entry=ED9D4058-E661-02E9-E70A41706CD89724
--->
<cffunction name="onRequest" returnType="void">
<cfargument name="thePage" type="string" required="true">
<cfinclude template="#arguments.thePage#">
</cffunction>
<!--- Runs at end of request --->
<cffunction name="onRequestEnd" returnType="void" output="false">
<cfargument name="thePage" type="string" required="true">
</cffunction>
<!--- Runs when your session starts --->
<cffunction name="onSessionStart" returnType="void" output="false">
</cffunction>
<!--- Runs when session ends --->
<cffunction name="onSessionEnd" returnType="void" output="false">
<cfargument name="sessionScope" type="struct" required="true">
<cfargument name="appScope" type="struct" required="false">
</cffunction>
<!--- Runs on error --->
<cffunction name="onError" returnType="void" output="false">
<cfargument name="exception" required="true">
<cfargument name="eventname" type="string" required="true">
<cfdump var="#arguments#"><cfabort>
</cffunction>
<!--- Fired when user requests a CFM that doesn't exist. --->
<cffunction name="onMissingTemplate" returnType="boolean" output="false">
<cfargument name="targetpage" required="true" type="string">
<cfreturn true>
</cffunction>
</cfcomponent>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment