I am having a strange problem with my ColdFusion 10 code. I am new to ColdFusion, so itβs easy on me. The reason this is strange is because it does not seem to be found in older versions of this platform (i.e. MX 7).
A little information:
I have two environments. ColdFusion 10 and ColdFusion MX 7 (IIS 7 and IIS 5, respectively). In ColdFusion 10 environment, I have an Application.cfc file with the following statement ...
<cfset CompanyLogoText = "Acme Company">
This Application.cfc file is located in the root directory (mydomain.com). I also have a CFM file in a web root subfolder in mydomain.com/pages/default.cfm . It contains the following markup ...
<cfoutput><p>#CompanyLogoText#</p></cfoutput>
Problem
When I go to mydomain.com/pages/default.cfm , I get an error from coldfusion. Error: "COMPANYLOGOTEXT variable undefined."
Strange part
I do not get this error in ColdFusion MX 7. The only difference is that the CF MX 7 environment uses the Application.cfm file, but with the same exact line.
Question
How can I get the pages/default.cfm file to view my CompanyLogoText variable in CF 10?
Here is the complete markup
Application.cfc
<cfcomponent> <cfset This.name = "test_cf"> <cfset This.Sessionmanagement="yes"> <cfset This.Sessiontimeout="#createtimespan(0,0,10,0)#"> <cfset This.applicationtimeout="#createtimespan(5,0,0,0)#"> <cfset This.setclientcookies="no" > <cfset This.clientmanagement="no"> <cffunction name="onApplicationStart"> <cfset CompanyLogoText = "Acme Company"> </cffunction> <cffunction name="onRequestStart"> <cfargument name="requestname" required=true /> <cfset CompanyLogoText = "Acme Company"> </cffunction> </cfcomponent>
Pages / Default.cfm
<cftry> <cfoutput><p>#CompanyLogoText#</p></cfoutput> <cfcatch> <p>Could not read CompanyLogoText<br/><br/> <cfoutput> <br/>Message: #cfcatch.message# <br/>Details: #cfcatch.detail#. </cfoutput> </cfcatch> </cftry>
scope coldfusion coldfusion-10
Ryancji
source share