User Guide

Table Of Contents
CFC variables and scope 227
You can pass positional parameters to a method by separating them with commas. The
following example calls the
getAuth method, and passes the name and password as positional
parameters:
authorized = securityCFC.getAuth("Almonzo", "LauRa123");
Note: For more information on using positional parameters and component methods in
ColdFusion functions, see “Creating user-defined functions” on page 172.
Passing parameters in a URL
ColdFusion lets you pass parameters to CFC methods in a URL. To do so, you append the URL
in standard URL query-string, name-value pair syntax; for example:
http://localhost:8500/CompanyQuery.cfc?method=getEmp&lastName=Adams
CFC variables and scope
This section describes how CFCs interact with ColdFusion scopes and use local variables,
including the following topics:
The This scope
The Variables scope
The Arguments scope
Other variable scopes
Function local variables
Note: Components also have a Super keyword that is sometimes called a scope. For information on
the Super keyword, see “Using the Super keyword” on page 232.
The This scope
The This scope is available within the CFC and is shared by all CFC methods. It is also available
in the base component (if the CFC is a child component), on the page that instantiates the CFC,
and all CFML pages included by the CFC.
Inside the CFC, you define and access This scope variables by using the prefix This, as in the
following line:
<cfset This.color="green">
In the calling page, you can define and access CFC This scope variables by using the CFC
instance name as the prefix. For example, if you create a CFC instance named
car and, within the
car CFC specify <cfset This.color="green">, a ColdFusion page that instantiates the CFC
could refer to the component’s color property as
#car.color#.
Variable values in the This scope last as long as the CFC instance exists and, therefore, can persist
between calls to methods of a CFC instance.
Note: The This scope identifier works like the This keyword of JavaScript and ActionScript. CFCs do
not follow the Java class model, and the This keyword behaves differently in ColdFusion MX than in
Java. In Java, This is a private scope, whereas in ColdFusion, it is a public scope.