O'Reilly logo

Programming ColdFusion MX, 2nd Edition by Rob Brooks-Bilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Components

Now that you understand how to create a basic component, let’s discuss how to use them in your applications. Typically, you create an instance of a component and then call a method on it, passing data in the form of arguments. The component does something based on the arguments passed and may return data to the calling page. That’s component interaction in a nutshell. You have quite a bit of choice, however, in how you make it all work. There are seven basic ways in which you can call a component. These include the following:

cfinvoke tag

Instantiates a CFC and/or invokes a method on an instantiated CFC.

cfobject tag

Instantiates a CFC. Properties must be explicitly set, and methods explicitly called.

createObject( ) function

Instantiates an object via cfset, cfparam, or cfscript. Properties must be explicitly set, and methods explicitly called.

URL

Invokes a component method directly via an HTTP GET. The CFC filename is specified in the URL along with the method name as a URL parameter.

Form post

The Action attribute of an HTML form or cfform tag posts directly to a CFC. The method to call must be specified by a form field.

Web service

CFCs can be consumed as web services. For more information, see Chapter 24.

Flash Remoting

Flash MX animations can call ColdFusion components via Flash Remoting. For more information, see Chapter 28.

Using cfinvoke

In an effort to make working with CFCs and methods as simple as possible, let’s break each of these techniques down. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required