Adobe COLDFUSION 9 Manual page 203

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
2
You can pass the parameters in an
previous example:
argsColl = structNew();
argsColl.username = "Almonzo";
argsColl.password = "LauRa123";
authorized = securityCFC.getAuth(argumentCollection = argsColl);
3
You can pass positional parameters to a method by separating them with commas. The following example calls the
method, and passes the name and password as positional parameters:
getAuth
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 153.
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
CFCs interact with ColdFusion scopes and use 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 202.
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
"
, a ColdFusion page that instantiates the CFC could refer to the component's color property as
This.color=
green">
.
#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 in JavaScript and ActionScript. CFCs do not follow the Java
class model, and the This keyword behaves differently in ColdFusion than in Java. In Java, This is a private scope, whereas
in ColdFusion, it is a public scope.
The Variables scope
The Variables scope in a CFC is private to the CFC. It includes variables defined in the CFC body (initialization or
constructor code) and in the CFC methods. When you set Variables scope variables in the CFC, they cannot be seen
by pages that invoke the CFC.
structure. The following code is equivalent to the
argumentCollection
and, within the
car
Last updated 8/5/2010
CFC specify
car
<cfset
198

Advertisement

Table of Contents
loading

Table of Contents