Creating ColdFusion components
When you create CFCs, you create methods, which are ColdFusion
user-defined functions, in the component page. You pass data to
a method by using parameters. The method then performs the function
and, if specified in the cfreturn tag, returns data.
You can also define variables in a CFC. Within a CFC, these variables
are known as properties.
Tags for creating CFCs
You use the following tags to create
a CFC. You include these tags on the CFML page that defines the
CFC.
Elements of a CFC
A CFC has the following characteristics:
It is a single CFML page with a .cfc filename extension.
The component name is the same as the filename. For example, if
the file is myComponent.cfc, the component name is myComponent.
The page is surrounded by a cfcomponent tag. No code can be outside
this tag.
The component page defines methods (functions), properties
(data), or both. Most CFCs have methods, or methods and properties,
but you can also have a CFC that contains only properties.
You use the cffunction tag to define CFC methods.
The CFScript function statement can create simple
methods, but it does not provide options to control access to the
method, provide metadata, specify a return type, or control generated
output.
You can write code on the component page that is outside cffunction definitions.
This code executes when the CFC is instantiated or whenever you invoke
a method of the CFC.