Ketan Jetty
enthusiasm for technology


<cfcomponent output="false">
	<cfscript> = "myApplicationName";
		this.applicationTimeout = createTimeSpan(8,0,0,0);
		this.clientManagement = false;
		//this.clientStorage = "registry";
		//this.loginStorage = "session";
		this.sessionManagement = false;
		//this.sessionTimeout = createTimeSpan(0,0,0,0);
		this.setClientCookies = false;
		this.setDomainCookies = false;
		this.scriptProtect = false;
		this.secureJSON = false;
		this.secureJSONPrefix = "";
		this.welcomeFileList = "";

	<cffunction name="onApplicationStart" returnType="boolean" output="false">
		<cfreturn true />

	<cffunction name="onApplicationEnd" returnType="void" output="false">
		<cfargument name="applicationScope" required="true" />
		<cfreturn />
	<cffunction name="OnSessionStart" access="public" returntype="void" output="false">
		<cfreturn />
	<cffunction name="OnSessionEnd" access="public" returntype="void" output="false">
		<cfargument name="SessionScope" type="struct" required="true" />
		<cfargument name="ApplicationScope" type="struct" required="false" default="#StructNew()#" />	 	
	 	<cfreturn />

	<cffunction name="onRequestStart" returnType="boolean" output="true">
		<cfargument name="thePage" type="String" required="true" />		
		<cfreturn true />

	<!---cffunction name="onRequest" returnType="void" output="false">
		<cfargument name="thePage" type="String" required="true" />
		<cfreturn />

	<cffunction name="onRequestEnd" returnType="void" output="false">
		<cfargument name="thePage" type="String" required="true" />
		<cfreturn />
	<cffunction name="onMissingTemplate" returnType="boolean" output="false">
		<cfargument name="targetpage" type="String" required="true" />
		<cfreturn true />

	<!---cffunction name="onError" returnType="void" output="false">
		<cfargument name="exception" required="true" />
		<cfargument name="eventname" type="String" required="true" />
		<cfreturn />

We use This scope within Application.cfc fileto set the attributes that are normally set in the application.cfm using the cfapplication tag.

onApplicationStart: this method will be invoked only once and the very first time a user hits your application (after the CF is started/restarted). As this is called only once this is the right place to create application scope variables and there is no need for the "cflock" and "isDefined()" code in this section. You need to return true for this method, returning false will will not start the application. This method runs as a STA model (single threaded apartment module). notes: if missing the application scope will be a pointer to the server object.

onSessionStart: this method is invoked the very first time a new user hits your application. A returning user with a valid current session will not trigger this method. this method can be used to set session scope data eg. shopping cart

onRequestStart: this method is invoked for each and every hit to the application. cf passes the script name as an argument to allow the programmer write some optional validation/security checks here. You need to return true, returning false will abruptly stop the current request. note: any variables set here will not be available in the requested page. (what?). well its like this. if you want a variable set here set it in request scope.

onError: captures all errors/exceptions that are not captured by the cftry/cfcatch block(s). This methods has two arguments. The first is the exception object. The second is the name of the event that threw an error. You can write code to log/mail the error. Also it is a better idea to use cflocation tab to redirect the user a user friendly error page. Please note onError takes precendence over any error handler code other than cftry/cfcatch.

onApplicationEnd: this method is invoked by the cf engine whenever the application timesout or when you stop/restart your application. The method receives the application scope as an argument. Any changes to the passed argument applicationScope will be reflected in the actual application scope as the application scope's pointer is passed in the argument. note: at this point the application scope is not available.

onSessionEnd: this method is invoked whenever a session timesout. application scope (as a pointer) and session scope is passed to this method. Please do not modify the application scope directly here. note: at this point both application and session scope are not available.

onRequestEnd: this method will be auto-invoked at the end of every request. this is akin to having a OnRequestEnd.cfm file in the folder.

onRequest: (suggesstion) Do not use this method. this method is basically used to override the requested page so that an alternate page can be loaded in its place. If you want the original requested page to be executed then you should use cfinclude to include the page using the passed page argument. Note: this method will break Flash Remoting and Web Service calls.
1. to get around this create another subdirectory and add a new Application.cfc without the onRequest method.

This: The "This" structure contains all data about the CFC and what its methods. they're aren't


CF Quick Reference

Ginger CMS
the future of cms, a simple, easy and intutive content management system ... more

cf prototyping engine, generates boilerplate code and ... more

Jrun monitor
monitor and timely auto-restart to avoid Jrun hang ... more

Inheritance Config.
uses OOPs inheritance to create configuration file ... more

Real Estate App.
complete real estate application using data from MLS ... more

Search Engine Lite
create your own search engine for your web site ... more