Upload
cfjedimaster
View
339
Download
0
Tags:
Embed Size (px)
DESCRIPTION
private test
Citation preview
Application.cfc and ColdFusion MX 7
Raymond Camden
August 30, 2006
Overview
The Old Days
Introduction to Application.cfc
onApplicationStart/End
onSessionStart/End
onRequestStart/End
onError
onRequest
Things to Look Out For…
The Old Days
Application.cfm
Loaded before any ColdFusion page CF looks in current, and parent folders It’s really just an “automatic include”! Uses <cfapplication> to define application
OnRequestEnd.cfm
Loaded at the end of a CFM page CF looks in the current, and higher, folder
– But if it finds an Application.cfm file, it will stop looking
It’s really just an “automatic include”!
Application.cfc – the Future is Now!
Application.cfc
How is the file found? Defining settings Application.CFC Methods (think events)
Application.cfc - Settings
Name ApplicationTimeout ClientManagement/ClientStorage/
SetClientCookies LoginStorage ScriptProtect (new in CFMX7) SessionManagement/SessionTimeout setDomainCookies
Application.cfc - Methods
onApplicationStart/End onSessionStart/End onRequestStart/End onError onRequest
onApplicationStart/End
Runs when application starts and ends (duh). There is no output when the application ends. Skip to the example…
onApplicationStart/End - Uses
Initializing Application Variables– No need for locking!
Logging– How many users were using my application?
– How long was my application alive?
onSessionStart/End
Runs when session starts and ends (duh). There is no output when the session ends. Pointers for Session/Application scope. NOT run when application ends/server shuts
down! Skip to the example…
onSessionStart/End - Uses
Initializing session variables Logging
– Track number of users
– How long did my session last?
– What is the average lifespan of a session?
– What was the last page of the session?
– What was the first page of the session?
onRequestStart/End
Runs when request starts and ends (duh). Just like Application.cfm and onRequestEnd.cfm. Variables set in the method do not exist in your
page. (An exception will be coming along shortly…)
Skip to the example…
onRequestStart/End - Uses
Security Setting request variables
onError
Runs when an error occurs (duh). Doesn’t reset the output Bug: onError called with cfabort Fixed with 7.0.2! (Not exactly) http://corfield.org/blog/index.cfm/do/blog.entry/entry/onError_onRequest_and_cfabort
onRequest
Allows specific control over the request. You must cfinclude the file! Copies methods, variables to Variables. Breaks FR and Web Services.
– Workaround (From Sean Corfield)
onRequest - Uses
Print Format Remove Whitespace Used Rarely
Things to Consider…
Loading UDFs
Extending Application.cfc– Tech Note:
http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=9ce734f4
– Sean Corfield’s Example: http://www.corfield.org/blog/index.cfm?do=blog.entry&entry=C8AF0DA4-0E78-FC9E-6975A16624A1E3C1
Converting from Application.cfm to Application.cfc
onRequest and WS/FR
Resources
My Bloghttp://ray.camdenfamily.com
Email [email protected] (home)
[email protected] (work)
Application.cfc Reference:
http://ray.camdenfamily.com/downloads/app.pdf