• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

22. ColdFusion Components > 22.2. Creating Components

Creating Components

Creating a CFC is easy. You simply define the component using the cfcomponent tag and save the file with a .cfc extension. cfcomponent is a paired tag that acts as a container for the CFC. Within the component, you can have any number of properties (defined by the cfproperty tag) and methods (each defined using a pair of cffunction tags). Each method can accept zero or more arguments, defined with cfargument tags. If a CFC returns any data, it does so with the cfreturn tag. Essentially, a component is a collection of related UDFs grouped within a cfcomponent container. Syntactically, a basic CFC looks like this:

<cfcomponent>
  <cfproperty />
  
  constructor code...
   
  <cffunction>
    <cfargument>
    CFML
    <cfreturn>
  </cffunction>
   
  <cffunction>
    <cfargument>
    CFML
    <cfreturn>
  </cffunction>
</cfcomponet>

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint