<CFPARAM> Tag - ColdFusion
>> Return to ColdFusion Tag Index
The <CFPARAM> tag allows you ...
<CFPARAM> Comments from Macromedia LiveDocs
LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-b13.htm
I described this issue to one of our developers and he entered bug 59937 for this.
LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-b13.htm
When you use a CFML structure and the square-bracket construct, the part inside the square brackets is any name you want - for example:
<cfset myStruct["Hello and Goodbye"] = 123 >
This creates an element in the structure myStruct named 'Hello and Goodbye'. The name includes the three words and two spaces.
ColdFusion makes the VARIABLES scope available as a structure. This means you can put anything into it - for example:
<cfset VARIABLES["Hello and Goodbye"] = 123 >
The VARIABLES structure now contains an element named 'Hello and Goodbye'.
However, you cannot use this element as a CFML variable because it has an illegal name because of the spaces. For example, this won't work:
<cfset VARIABLES.Hello and Goodbye = 456 >
Adding elements to the VARIABLES structure is legal, just like any structure.
Adding elements with any name is allowed, but this does not turn elements with illegal names into bona fide CFML variables.
In short - <cfset VARIABLES["anyname"] = somevalue> is not forbidden by the CFML language, but it is not a recommended way of coding CFML.
LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-b13.htm
It looks like cfparam does not set values to proper variable and can modify variable when you did not expect it to be modified.
I think it is a dangerous bug, that can make debugging a real hell.
Please consider the following code:
<code>
<cfset variables["a"] = 0 >
<cfparam name="a " type="string" default="2">
<cfoutput>'a'=#variables["a"]#<br></cfoutput>
<cfoutput>'a '=#variables["a "]#</cfoutput>
</code>
The result is "'a'=2 'a '=" and an exception: "Element a is undefined in a Java object of type class coldfusion.runtime.VariableScope referenced as"
However, if I modify this code as shown bellow:
<code>
<cfset variables["a"] = 0 >
<cfset variables["a "] = 1 >
<cfparam name="a " type="string" default="2">
<cfoutput>'a'=#variables["a"]#<br></cfoutput>
<cfoutput>'a '=#variables["a "]#</cfoutput>
</code>
The result is more intuitive: "'a'=0 'a '=1" and no exception thrown.
LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-b13.htm
After some testing I discovered that it's:
1. variables
2. url
3. form
The following scopes are not checked:
- request
- session
- clients
- application
Can anyone confirm this?
LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-b13.htm
What is the order of scope when cfparam is used?
That is not stated.
LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-b13.htm
"numeric: a numeric value",
"date: a date-time value"
This page is supposed to document the <cfparam> tag.
Can you document which numeric values
and date-time values are considered valid? Please explain influence of the locale setting. Eg in some parts of the world 123,456,789.00 is not valid number.
LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-b13.htm
There is a difference between 6.0 and 6.1 when using cfparam to create nested structs. The statement <cfparam name="session.a.b.c.d.e" default="1"> works fine on 6.1, creating a nested structure, the innermost element having the correct value of 1.
However, on 6.0, it doesn't properly create it, and will leave you with a "session.c.d.e" structure in place -- the a and b elements are not created. It appears that cfparam has some sort of maximum levels that it can cope with.
LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-b13.htm
The following information is true and should be added in future releases of the documentaiton:
Any expression used for the default attribute will be evaluated even if the parameter exists. The result will not be assigned if the parameter exists, but if the expression has side effects, they will still occur.
LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-b13.htm
It is not made clear by the documentation that any code in the DEFAULT parameter <em>is</em> executed, <strong>even if the variable already exists</strong>. This becomes relevant if the default value calls a component method that might change the state of the component, or the state of something else within the system.
This stands to reason if one is to stop and think about it, I guess: but it's easy to never stop and think about it :-)
Adam
[Top]
Recommended Books
COLDFUSION MX Web Application Construction Kit (5th Edition)
Authors: Ben Forta and Nate Weiss
1500 pages
[Top]
Web Sites
Macromedia
The makers of ColdFusion/ColdFusion MX.
ColdFusion Developer's Journal
Forta.com (ColdFusion Section)
Ben Forta is Macromedia's Senior Technical Evangelist. Here on his site find useful ColdFusion information.
Flash CFM
Flash and ColdFusion Development.
Handling file uploads without CFFILE
BLOG post by "Sam" on REWINDLIFE.COM gives insight into how to upload a file on your site if you are not allowed to use the CFFILE tag.
[Top]
Copyright © 2003- 2008, Orville Paul Chomer, All Rights Reserved
Home Page
Blog
How To
Chomer TV
The Show
Webcam Videos
Freeware
•
VB Mahjongg
Coding
•
ColdFusion
•
Javascript
•
Visual Basic
Other Places
Acoustic Eidolon
History Singers
Scobleizer
Beach Walks
Freshtopia
CSS Zen Garden