Adobe COLDFUSION 9 Manual page 202

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
Passing parameters by using attribute format
You can pass parameters in the
<cfinvoke component="authQuery" method="getAuthSecure"
lastName="#session.username#" pwd="#url.password#">
In the example, the parameters are passed as the
Note: The
tag attribute names are reserved and cannot be used for parameter names. The reserved attribute
cfinvoke
names are:
,
component
method
Reference.
Passing parameters in the argumentCollection attribute
If you save attributes to a structure, you can pass the structure directly using the
attribute. This technique is useful if an existing structure or scope (such as the Forms scope) contains values that you
want to pass to a CFC as parameters, and for using conditional or looping code to create parameters.
When you pass an argumentCollection structure, each structure key is the name of a parameter inside the structure.
The following example passes the Form scope to the
each form field name is a parameter name; the method can use the contents of the form fields to add a user to a
database.
<cfinvoke component="UserDataCFC" method="addUser" argumentCollection="#Form#">
Passing parameters by using the cfinvokeargument tag
To pass parameters in the
cfinvoke
example, you can build conditional processing that passes a different parameter based on user input.
The following example invokes the
<cfinvoke component="corpQuery" method="getEmp">
<cfinvokeargument name="lastName" value="Wilder">
</cfinvoke>
The
tag passes the
cfinvokeargument
In the following example, a form already let the user select the report to generate. After instantiating the
components, the action page invokes the
reports
. The action page then invokes the
queryall
pass the query results to the
<cfobject component="getdata" name="doquery">
<cfobject component="reports" name="doreport">
<cfinvoke component="#doquery#" method="#form.whichreport#" returnvariable="queryall">
<cfinvoke component="#doreport#"method="#form.whichreport#">
<cfinvokeargument name="queryall" value="#queryall#">
</cfinvoke>
Passing parameters in direct method invocations
ColdFusion provides three methods for passing parameters to CFC methods in direct method invocations:
You can pass the parameters the form of comma-separated
1
example:
authorized = securityCFC.getAuth(name="Almonzo", Password="LauRa123");
tag as tag attribute name-value pairs, as the following example shows:
cfinvoke
lastName
,
, and
argumentCollection
addUser
tag body, use the
cfinvokeargument
component:
corpQuery
parameter to the component method.
lastName
doquery
component instance and uses the
doreport
instance, where the output is generated.
doreport
Last updated 8/5/2010
and
attributes.
pwd
. For more information, see the CFML
returnVariable
cfinvoke
method of the UserDataCFC component. In the method,
tag. Using the
component instance, which returns the query results in
entries, as in the following CFScript
name="value"
tag's
argumentCollection
tag, for
cfinvokeargument
and
getdata
tag to
cfinvokeargument
197

Advertisement

Table of Contents
loading

Table of Contents