Adobe COLDFUSION 9 Manual page 212

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
• Information about any properties that are specified using the cfproperty tag.
Display metadata for a CFC
Create the tellAboutCfcs.cfm file in the same directory as the telltime.cfc file, with the following code:
1
<!--- Create an instance of the component. --->
<cfobject component="tellTime" name="tellTimeObj">
<!--- Create a 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
ColdFusion component example
Several code examples in the Developing ColdFusion Applications 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 Adobe 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="">
<cfquery name="engquery" datasource="cfdocexamples">
SELECT FirstName || ' ' || LastName AS FullName
FROM Employee
</cfquery>
</cffunction>
<cffunction name="bydept" access="public" output="false" returntype="query">
<cfset var deptquery="">
CFCs" on page 187.
Last updated 8/5/2010
207

Advertisement

Table of Contents
loading

Table of Contents