How Do I Use ColdFusion Components (CFCs)?
Print this Article
Comment on this Article
Last Updated:
February 19, 2007 8:48 AM
A ColdFusion component (CFC) is a file saved with the extension .cfc. Like custom tags, CFCs are a way to encapsulate your code for use on other ColdFusion pages. However, CFCs have several advantages over custom tags, including:
- CFCs can bundle a number of different functions in one component
- CFCs can define properties that multiple methods can then share
- CFCs support more advanced "object oriented" techniques, like inheritance
- CFCs can provide easy support for web services and Flash Remoting MX
Creating and using CFCs is a fairly involved topic. See Macromedia's livedocs for more information.
To call your CFC, you will need to use the <cfinvoke> tag. The <cfobject> tag and the CreateObject function are disabled on our servers for security reasons. For example, the following code will call the sayHello function on a CFC named hello.cfc:
<cfinvoke component="hello" method="sayHello">