Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Building ColdFusion components > Defining component methods Defining and using method parameters PreviousNext

Defining and using method parameters

To define the component method parameter, use the cfargument tag in the cffunction tag body. To define multiple parameters, use multiple cfargument tags. You can create CFC methods that do not use cfargument tags, for example, if you use positional parameters in your methods. However, most CFC methods use the cfargument tag. The tag names a parameter and lets you specify the following:

For detailed reference information on the cfargument tag, see CFML Reference.

To access the parameter values in the component method definition, use structure- or array-like notation with the Arguments scope. The following example refers to the lastName argument as Arguments.lastName; it could also refer to it as Arguments[1]. In addition, you can access arguments directly using pound signs, such as #lastName#; however, it is better programming practice to identify the scope. Also, you can use Array- or structure-like notation, which lets you loop over multiple parameters.

For more information on the Arguments scope, see The Arguments scope.

Note: For the following procedure to work, you must have the example applications installed with ColdFusion MX. For more information, see CFML Reference.

To define parameters in the component method definition:

In the example, the cfargument attributes specify the following:

The Arguments variable scope provides access to the parameter values.


Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Building ColdFusion components > Defining component methods Defining and using method parameters PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.