> Ok. So if I want to create a global var that's almost always the same (with a > few exceptions), I could do the following in the application.cfc: > > Set up the application vars I always want available. > > <cffunction > name="OnApplicationStart"access="public"returntype="boolean" output="false" > hint="Fires when the application is first created."> > <cfset application.mystandardvar = "foo"> > <cfset application. myoverridevar = "kungfoo"> > </cffunction> > > Set up the most standard use like below (which should make it available on > all pages): > > <cffunction name="OnRequestStart" access="public" returntype="string" > output="true" hint="Fires at first part of page processing."> > <cfset thepagevar="#application.mystandardvar#"> > </cffunction> > > Then, on the exception pages where I want to use the other variant, I can do > the following at page top: > > <cfset thepagevar="="#application.myoverridevar#"> > > > This will make all occurrences of "thepagevar" the same as > application.mystandardvar, except on those pages where I did the additional > cfset at page top, in which case it will be application. Myoverridevar for > that page only. > > Does this look correct?
Yes. But I don't necessarily see the value of using Application variables at all in this example. You could just as easily set a page or Request variable in onRequestStart, and override it as needed on individual pages. The value of using Application variables really comes from one or the other of these two use cases: 1. It's expensive to create the variable. That doesn't appear to be the case here. 2. The value of the variable will change over the life of the application. While that's true on its face here, as some pages will have one value and other pages will have another, that's not really a match for the use case, as these changes don't happen over the life of the application - they're just different values for different pages. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:348843 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

