Creates and defines a component object; encloses functionality that you build in CFML and enclose in cffunction tags. This tag contains one or more cffunction tags that define methods. Code within the body of this tag, other than cffunction tags, is executed when the component is instantiated.

A component file has the extension CFC and is stored in any directory of an application.

A component method is invoked in the following ways:

  • In the cfinvoke tag in a ColdFusion page

  • In a URL that calls a CFC file and passes a method name as a URL parameter

  • In the cfscript tag

  • As a web service

  • From Flash code


    accessors = "yes|no" 
    alias = "ActionScript 3 type alias" 
    bindingname = "binding element name" 
    displayname = "string" 
    extends = "component name" 
    hint = "string" 
    implements = "ColdFusion interface" 
    mappedSuperClass = "yes|no" 
    namespace = "default service namespace" 
    output = "no value|no|yes" 
    porttypename = "port type element name" 
    Serializable = "yes|no" 
    serviceaddress = "service URL" 
    serviceportname = "port element name" 
    style = "rpc|document" 
    wsdlfile = "path"> 
    variable declarations 
    <cffunction ...> 
    <cffunction ...> 


ColdFusion 9.0.1: Added the attribute mappedSuperClass

ColdFusion 9: Added the attributes serializable and accessors.

ColdFusion 8:

  • Added the implements and serviceaddress attributes.

  • Added support for the onMissingMethod function.

ColdFusion MX 7:

  • Added support for publishing document-literal style web services.

  • Added the style, namespace, serviceportname, porttypename, wsdlfile, bindingname, and output attributes.

  • Extended functionality for the hint and displayname attributes when publishing document-literal style web services.

ColdFusion MX: Added this tag.








yes (for persistent CFC)

no for others

If set to yes, lets you invoke implicit getters and setters.

For persistent CFC, accessors is always enabled.



Specifies the type label to give the object when it is converted from CFML to ActionScript 3. It matches the alias attribute of AS3 types. This is attribute applies only to Flash Remoting and LiveCycle Data Services value objects, and lets you work with typed objects in both ColdFusion and Flash.



Specifies the binding attribute of the port element in the WSDL. If you don’t specify this attribute, ColdFusion derives the value from the CFC class name.



A string that displays when you use introspection to show information about the CFC. The information appears on the heading, following the component name.




Name of parent component from which to inherit methods and properties. You can use the keyword component to specify the default value.



Text that displays when you use introspection to show information about the CFC. The hint attribute value appears below the component name heading. Use this attribute to describe the purpose of the parameter.



Name of the ColdFusion interface or interfaces that this component implements. If the component implements an interface, it must define all the functions in the interface, and the function definitions must conform to the definitions specified in the interface. For more information, see cfinterface.

A component can implement any number of interfaces. To specify multiple interfaces, use a comma-delimited list with the format interface1,interface2.


Added in ColdFusion 9.0.1



If set to yes on a non-persistent CFC, child CFCs can inherit its properties. For example, you can define a base CFC with common properties such as ID, version, or createdOn which all other persistent CFCs would extend and thus get one common behavior.

mappedSuperClass cannot be set to yes on a persistent CFC.



class name

Specifies the namespace used in the WSDL for a CFC that is invoked as a web service. If you don’t specify this attribute, ColdFusion derives the value from the CFC class name.



Component body displayable text that is processed as standard CFML

Specifies whether constructor code in the component can generate HTML output; does not affect output in the body of cffunction tags in the component.

  • yes: Constructor code is processed as if it were within a cfoutput tag. Variable names surrounded by number signs (#) are automatically replaced with their values.

  • no: Constructor code is processed as if it were within a cfsilent tag.

  • If you do not specify this attribute, constructor code is processed as standard CFML. Any variables must be in cfoutput tags.



Specifies the name attribute of the porttype element in the WSDL. If you don’t specify this attribute, ColdFusion derives the value from the CFC class name.




Specifies whether this component can be serialized. If you set this value to false, the component and the data in the component’s This and Variables scopes cannot be serialized, so they are not retained on session replication, and the component is in its default state.



URL of the CFC

Specifies the SOAP URL of the web service. If you don’t specify this attribute, ColdFusion uses the URL of the CFC in the WSDL service description. Use this attribute to specify the protocol, for example, by specifying a URL that starts with https://.

This attribute applies only for web services.



Specifies the name attribute of the port element in the WSDL. If you don’t specify this attribute, ColdFusion derives the value from the CFC class name.




Specifies whether a CFC used for web services uses RPC-encoded style or document-literal style:

  • rpc: RPC-encoded style

  • document: Document-literal style



A properly formatted WSDL file to be used instead of WSDL generated by ColdFusion.


If you specify the extends attribute, the data and methods of the parent component are available to CFC methods as if they were parts of the current component. If the managerCFC component extends the employeeCFC component, and the employeeCFC component has a getEmployeeName method, you can call this method by using the managerCFC, as follows:

<cfinvoke component="managerCFC" method="getEmployeeName" returnVariable="managerName" 

This tag requires an end tag.

If you specify style="document", ColdFusion publishes the CFC as a document-literal style web service. For more information, see Publishing document-literal style web services in the Developing ColdFusion Applications.

CFCs support an onMissingMethod function. By defining an onMissingMethod function in the cfcomponent tag body in the CFC, you can handle calls to methods that are not implemented in the CFC. If an application calls a function that is not defined in the CFC, ColdFusion calls the onMissingMethod function and passes it the requested method’s name and arguments. If you do not define an onMissingMethod function, a call to a method that is not defined in the CFC causes ColdFusion to throw an error that must be handled in the calling code.

The onMissingMethod function is useful for several purposes:

  • To handle errors directly in the component, instead of requiring that each instance of code that calls the component handles them.

  • To create a dynamic proxy, an object that can take arbitrary calls and dynamically determines the correct action.

The onMissingMethod function must have the following format:

<cffunction name="onMissingMethod"> 
    <cfargument name="missingMethodName" type="string"> 
    <cfargument name="missingMethodArguments" type="struct"> 
        code to handle call to nonexistent method 
Note: The argument name for onMissingMethod must not change.


    <cffunction name="getEmp"> 
         <cfquery name="empQuery" datasource="cfdocexamples" > 
             FROM tblEmployees 
         <cfreturn empQuery> 
    <cffunction name="getDept"> 
        <cfquery name="deptQuery" datasource="cfdocexamples" > 
             SELECT * 
             FROM tblDepartments 
         <cfreturn deptQuery>