Copy link to clipboard
Copied
I inherited a Club website and a copy of CF for Dummies. All went well until my ISP upgraded. Now I can't pass variables between pages. What to do?
Let's take your previous example:
Testsend.cfm
<html>
<head><!--- Nothing ---></head>
<body><cfoutput><a href = "testreceive.cfm?varmy=10">Click</a></cfoutput></body>
</html>
Testreceive.cfm
<html>
<head> <!--- Nothing ---></head>
<body><cfoutput>Received variable: #varmy#<br></cfoutput></body>
</html>
Since varmy is a URL variable, that is, one that comes in through the query string, you should "scope" it as follows:
<body><cfoutput>Received variable: #url.varmy#<br></cfoutput></body>
Yes, th
...Copy link to clipboard
Copied
What to do depends on your code. For some code, you don't even have to pass variables between pages.
If you shared the code, you would certainly get suggestions on how to solve the problem.
Copy link to clipboard
Copied
Like @BKBK recommended, you should definitely share your code. In addition to that, you should provide some additional details. What got upgraded exactly? What errors are you seeing? What version of CF is covered by your book? Basically, any information you can provide may help us help you.
Copy link to clipboard
Copied
The original code called on javascript to display a larger version of a small (width-180) picture in a gallery of several lines of 4 pictures per line. The larger version would close after a number of seconds passed as a second variable.
This works on my home set-up and used to work at my ISP.
Having hit a brick wall with the new set-up at my ISP, I removed the javascript and added a “Close” button to the larger picture to return to the gallery. Not ideal.
This is within two loops for the number of lines in the gallery and a 1 to 4 loop for pictures per line
<td valign = top><p align = "center">#a_title[jk]#</p><a href = "windowpics.cfm?tramp=#jk#"><img src="gallery/#a_pic[jk]#.jpg" width = 180></a></td>
This works in my home set-up, but when showing windowpics.cfm, the ISP delivers “Variable TRAMP is undefined”
My next attempt was to write two minimalist programs without any CF code
Testsend.cfm
<html>
<head><!--- Nothing ---></head>
<body><cfoutput><a href = "testreceive.cfm?varmy=10">Click</a></cfoutput></body>
</html>
Testreceive.cfm
<html>
<head> <!--- Nothing ---></head>
<body><cfoutput>Received variable: #varmy#<br></cfoutput></body>
</html>
This works at home but gives “Variable VARMY is undefined”.when trying to run testreceive.cfm
My home set-up is whatever Adobe was offering in 2015. The ISP has gone to Version 2021 which does not support MsAccess – which is a whole new set of problems.
Copy link to clipboard
Copied
I am assuming you are on ColdFusion 2023. Then my guess is that the issue is caused by a change in the language, starting from Update 7 of ColdFusion 2023.
Up until then, if you defined a variable, myVar, without specifying the scope, ColdFusion would automatically look for myVar in every relevant scope.
That behaviour has been changed. From Update 7 onwards, you must explicitly state the intended scope of each variable, for example,
url.varmy
Otherwise, you get an error.
However, there is an alternative. If you want ColdFusion to revert to its old, pre-Update-7 behaviour (that is, automatically search for a variable across every relevant scope), then you will have to proceed as follows:
<cfset this.searchimplicitscopes=true>
Copy link to clipboard
Copied
Do you need assistance with "JVM arguments" or with "Application.cfc"? Then the forum can help.
Copy link to clipboard
Copied
Until now I have never had to deal with scopes. I was able to pass variables between templates by using
<a href="nextpage.cfm?varmy=#xyz#">Click</a> or in the "Action" section of a form. What kind of scope do I now need to pass a variable between templates? How and where do I define the scope?
Using
<cfset this.searchimplicitscopes=true>
is tempting, but the documentation says it will soon disappear.
Copy link to clipboard
Copied
Let's take your previous example:
Testsend.cfm
<html>
<head><!--- Nothing ---></head>
<body><cfoutput><a href = "testreceive.cfm?varmy=10">Click</a></cfoutput></body>
</html>
Testreceive.cfm
<html>
<head> <!--- Nothing ---></head>
<body><cfoutput>Received variable: #varmy#<br></cfoutput></body>
</html>
Since varmy is a URL variable, that is, one that comes in through the query string, you should "scope" it as follows:
<body><cfoutput>Received variable: #url.varmy#<br></cfoutput></body>
Yes, the documentation says there will be no searchImplicitScopes flag from ColdFusion 2025 onwards.
Copy link to clipboard
Copied
Thanks - youv'e made my day!
J
Copy link to clipboard
Copied
Guys, while it's great that judo has solved the problem with hard-coding the scope, let's clarify about solving it otherwise.
First, despite what the docs say, the jvm arg IS in fact supported in cf2025. Adobe reversed their plans after that March 2024 update that introduced this. (FWIW, they did not reverse their removal in cf2025 of the similar cfmx_compat arg that came out with the Apr 2024 update.)
Second, though, note that the ability to control this at the app level (setting searchimplicitscope in cfapplication or in an application.cfc) was NOT indicated to be removed at all. It was only the jvm arg approach--which has been reversed for now.
All that said, there's certainly a security argument for correcting code rather than app or jvm level settings.
Copy link to clipboard
Copied
Thanks - youv'e made my day!
J
By @judo1
My pleasure.
Should you be looking for a way to use Application.cfc to free you from having to add the "url" scope, here is a tip.
Store the following code as Application.cfc in the same directory as the CFM files.
<cfcomponent>
<!--- Application settings --->
<cfset this.name = "MyTestApp">
<cfset this.sessionManagement = true>
<cfset this.sessionTimeout = createTimeSpan(0, 0, 20, 0)>
<cfset this.applicationTimeout = createTimeSpan(1, 0, 0, 0)>
<cfset this.searchImplicitScopes = true>
<!--- Called when the application is first initialized --->
<cffunction name="onApplicationStart" returnType="boolean">
<cfreturn true>
</cffunction>
<!--- Called when a session starts --->
<cffunction name="onSessionStart" returnType="void">
</cffunction>
<!--- Called for every request --->
<cffunction name="onRequestStart" returnType="boolean">
<cfargument name="targetPage" type="string" required="true">
<cfreturn true>
</cffunction>
</cfcomponent>
With Application.cfc in place, you can now use the following code as before:
<!--- Specifying the "url" scope is now optional. However, it is recommended to do so. --->
<body><cfoutput>Received variable: #varmy#<br></cfoutput></body>
Find more inspiration, events, and resources on the new Adobe Community
Explore Now