User Guide

Table Of Contents
ColdFusion component example 239
Within each function structure, a Parameters element that contains an array of parameters
specified by
cfargument tags. Information on each parameter includes any metadata-only
attributes.
Information about any properties that are specified using the cfproperty tag.
To display metadata for a CFC:
1.
Create the tellAboutCfcs.cfm file in the same directory as the telltime.cfc file, with the following
code:
<!--- Create an instance of the component. --->
<cfobject component="tellTime" name="tellTimeObj">
<!--- Create a new structure. --->
<cfset aboutcfc=structNew()>
<!--- Populate the structure with the metadata for the
tellTimeObj instance of the tellTime CFC. --->
<cfset aboutcfc=GetMetaData(tellTimeObj)>
<cfdump var="aboutcfc">
2.
View the tellAboutCfcs.cfm file in a browser.
For information on how to specify CFC metadata, including how to use component tags and how
to specify metadata-only attributes, see “Documenting CFCs” on page 214.
ColdFusion component example
A number of code examples in ColdFusion MX Developers Guide reuse code, particularly queries.
To illustrate the advantages of CFCs, these examples invoke the appropriate method in the CFC
that appears in the following example. Although Macromedia recommends using CFCs to create
structured, reusable code, some code examples in this manual contain queries within a CFML
page, rather than invoking a CFC, in order to clearly illustrate a particular element of
ColdFusion.
<cfcomponent>
<cffunction name="allemployees" access="public" output="false"
returntype="query">
<cfset var getNames="">
<cfquery name="getNames" datasource="cfdocexamples">
SELECT * FROM Employee
</cfquery>
</cffunction>
<cffunction name="namesalarycontract" access="public" output="false"
returntype="query">
<cfset var EmpList="">
<cfquery name="EmpList" datasource="cfdocexamples">
SELECT Firstname, Lastname, Salary, Contract
FROM Employee
</cfquery>
</cffunction>
<cffunction name="fullname" access="public" output="false"
returntype="query">
<cfset var engquery="">