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:
Instantiates a CFC and/or invokes a method on an instantiated CFC.
Instantiates a CFC. Properties must be explicitly set, and methods explicitly called.
an object via
cfscript. Properties must be explicitly set,
and methods explicitly called.
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.
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.
CFCs can be consumed as web services. For more information, see Chapter 24.
Flash MX animations can call ColdFusion components via Flash Remoting. For more information, see Chapter 28.
In an effort to make working with CFCs and methods as simple as possible, let’s break each of these techniques down. ...