Application.CFC Reference

The docs contain a nice reference to the new Application.CFC feature. One thing I think is missing is a simple diagram of the methods and what they expect and return. That information is in the docs, but what I want is a nice one page simple Application.cfc I can cut and paste. I also tend to forget what methods return what values, so such a reference would be handy.

So - I wrote up a simple CFC. I read the file in and then passed it to cfdocument, and voila - my Application.CFC reference was done. I'll be adding it to "My Tools" in a few moments.

Archived Comments

Comment 1 by Sean Corfield posted on 2/24/2005 at 5:34 AM

onSessionStart() returns a boolean, just like onApplicationStart() and onRequestStart()

Comment 2 by John Farrar posted on 2/24/2005 at 5:35 AM

OK... got a question on the session argument "appScope". Shouldn't this be application scope (beat myself on the head for missing that during the beta). Just asking.

Comment 3 by Darryl Lyons posted on 2/24/2005 at 6:17 AM

I nice reason to have Interfaces? :)

Comment 4 by Raymond Camden posted on 2/24/2005 at 6:22 AM

Sean - the docs say it returns void:

http://livedocs.macromedia....

I thought it was boolean as well.

John: In onSessionEnd, you can't access APPLICATION directly. You access it via a passed in argument. It is a reference so mods to the value will affect the App scope.

Comment 5 by John Farrar posted on 2/24/2005 at 6:41 AM

OK... got a question on the session argument "appScope". Shouldn't this be application scope (beat myself on the head for missing that during the beta). Just asking.

Comment 6 by Sean Corfield posted on 2/24/2005 at 7:24 AM

Weird, yes, void it is... I just tried returning false to abort the session / request but it didn't work. That seems a little inconsistent...

Comment 7 by tony petruzzi posted on 2/24/2005 at 9:49 PM

This has always been one of my biggest beefs with MacroMedia, their documentation. It's either incomplete or doesn't exist.

The biggest thing was when CFMX (6 and 6.1, not 7) was release. We heard how wonderful it will be to run mulitple instances. But when the product was release there was no simple, complete documentation anywhere telling you how to set this up. You had to hunt around the internet to find instructions from other people. There still isn't an easy, straight forward document explaining clustering in CFMX.

Granted you don't need this documentation now since CFMX7 has the most wonderful instance manager (I'm in love with it). I would love to see something like this for CFMX6.1. Wonder if you could pull it out of 7 and throw it into 6.1... hmmmmm. ;)

Comment 8 by luis aragon posted on 2/24/2005 at 10:51 PM

Is it possible to redirect a user to a login page when their session times out using onSessionEnd?

Comment 9 by Raymond Camden posted on 2/24/2005 at 10:55 PM

Technically no. Remember that CF defines a session as "a period of activity". So while your session will expire, CF can't force your browser to go somewhere. (That isn't 100% true. You CAN use JavaScript code to detect X amount of time and move the user.)

What you would want to do instead is make onSessionStart push the user to the login page. Actually - what I'd do instead is use onRequestStart. Make it check for a logged in flag, and if false, push the user there.

Comment 10 by Luis Aragon posted on 2/25/2005 at 12:00 AM

Please excuse my ignorance. I thought that onsessionend executed code when a session ends( 20 min of inactivity). I was thinking of trying to put a cflocation tag in the onsessionend tag to relocate a user to a login page when the session expires. Is that what you understood from my last post? If so, I apologize and thanks for the help.

Comment 11 by Raymond Camden posted on 2/25/2005 at 12:40 AM

It does execute the code, but it does it on the server. It's not on your browser. Remember that CF is all server side. If you idle for 20 mins, CF can't force your browser to do anything.

No need to apologize though. :)

Comment 12 by Luis Aragon posted on 2/25/2005 at 1:26 AM

Thanks for your help. What a major brain cramp. It can not push information to the browser. I guess since my application uses Flash Comm, I could write a push script to detect inactivity and force the user's screen to redirect to the login page.

Thanks for your help.

Comment 13 by Sean Corfield posted on 2/25/2005 at 2:49 PM

The main point to remember here is that onApplicationEnd() and onSessionEnd() happen asynchronously - so there is no request and therefore no associated browser.