I'm getting an error "transaction_types" is undefined, and having trouble understanding why.
I have application.cfc:
<cffunction name="onRequest" >
<cfargument name="targetPage" type="String" required=true/>
<cfinclude template="header.cfm">
</cffunction>
header.cfm file looks like this (header is called on every file and there is a different subheader depending on the directory the user is in):
<cfinclude template="#GetDirectoryFromPath(Arguments.targetPage)#subheader.cfm" />
The directory I'm having a problem with has two files, index.cfm and subheader.cfm
subheader.cfm, the first line
<cfset transaction_types = ["a", "b", "c"] />
part of index.cfm, and I think the issue might be the cflocation, but I'm not sure:
<cfif structKeyExists(url, "something") >
-- some database work is done here --
<cflocation url="index.cfm">
</cfif>
--further down on this page, transaction_types is used
I set the page up thinking transaction_types will be defined any time directory/index.cfm loads, since the application file always loads header.cfm and subsequently directory/subheader.cfm before directory/index.cfm. Does cflocation bypass this?
cflocationcall will go through the normal request processing. It does not call theonRequestmethod. They have documented that it behaves differently with theonRequestEndmethod as it does not get called either BUT it does call theonAbortmethod instead. From the docs: When using cfabort, cflocation, or cfcontent tags, the OnAbort method is invoked instead on OnRequestEnd. The call tocflocationalso stops processing of the current page. - Miguel-Fcflocationto should go through the normal request processing. So say you usecflocationto 'page2.cfm'. I think that page2.cfm will invoke theonRequestmethod but the initial page request is stopped when thecflocationtag fires. - Miguel-Fpart of index.cfm, and I think the issue might be the cflocation...Theindex.cfmscript is cflocating to itself ... is that a typo? FWIW, you can test whether cflocation calls OnRequest yourself. Create a separate Application.cfc and implement OnRequest. Inside OnRequest method display some text whenever the method is called, like:writeOutput("onRequest called");Create a test cfm page with a cflocation call. Run it and see if "onRequest called" appears at the top of the screen. - SOScflocationtag executes it stops the currently processing request, fires theonAbortmethod of Application.cfc, and then sends a 302 HTTP status code (by default) back to the user's browser. That in turn instructs the browser to make a new request of the URL included with that 302 status message. Which should start the process all over again to the new URL. - Miguel-F