MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 228

Developing coldfusion mx applications
Table of Contents

Advertisement

Using cfinvoke within the CFC definition
You can use the
for example, to call a utility method that provides a service to other methods in the component.
To use
cfinvoke
tag, as the following example shows:
cfinvoke
<cfinvoke method="getLocalTime">
Passing parameters to methods using cfinvoke
When you use the
parameters to CFC methods:
As
cfinvoke
In the
cfinvoke
In the
cfinvoke
You can use any combination of these methods in a single invocation. If you use the same name in
two or three of these methods, ColdFusion uses the value based on the following order of
precedence:
1
cfinvokeargument
attribute name-value pairs
2
cfinvoke
3
argumentcollection
Passing parameters using attribute format
You can pass parameters in the
example shows:
<cfinvoke component="authQuery" method="getAuthSecure"
lastName="#session.username#" password="#url.password#">
In the example, the parameters are passed as the
Note: The
cfinvoke
reserved attribute names are:
information, see CFML Reference.
Passing parameters in the argumentCollection attribute
If you save attributes to a structure, you can pass the structure directly using the
argumentCollection
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
the method, each form field name is a parameter name. Then the method can use the contents of
the form fields to add a user to a database.
<cfinvoke component="UserDataCFC" method="addUser"
argumentCollection="#Form#">
228
Chapter 11: Building and Using ColdFusion Components
tag to invoke a component method within the component definition;
cfinvoke
in this instance, do not create an instance or specify the component name in the
tag, ColdFusion MX provides several methods for passing
cfinvoke
tag attributes, in name="value" format
tag
argumentcollection
tag body, using
cfinvokeargument
tags
arguments
cfinvoke
tag attribute names are reserved and cannot be used for parameter names. The
component
attribute. This technique is useful if an existing structure or scope (such as
attribute
tag
tag as tag attribute name-value pairs, as the following
and
lastName
,
,
method
argumentCollection
addUser
attributes.
password
, and
returnVariable
cfinvoke
method of the UserDataCFC. In
. For more
tag's

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents