Creating And Using Custom Cfml Tags - Adobe 38043740 - ColdFusion Standard - Mac Development Manual

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
<cfquery name="deptquery" datasource="cfdocexamples">
SELECT Dept_ID, FirstName || ' ' || LastName
AS FullName
FROM Employee
ORDER BY Dept_ID
</cfquery>
</cffunction>
<cffunction name="employeebyURLID" access="public" output="false"
returntype="query">
<cfset var GetRecordtoUpdate="">
<cfquery name="GetRecordtoUpdate" datasource="cfdocexamples">
SELECT * FROM Employee
WHERE Emp_ID = #URL.Emp_ID#
</cfquery>
</cffunction>
<cffunction name="deleteemployee" access="public" output="false"
returntype="void">
<cfset var DeleteEmployee="">
<cfquery name="DeleteEmployee" datasource="cfdocexamples">
DELETE FROM Employee
WHERE Emp_ID = #Form.Emp_ID#
</cfquery>
</cffunction>
<cffunction name="distinctlocs"access="public" output="false"
returntype="query">
<cfset var GetDepartments="">
<cfquery name="GetDepartments" datasource="cfdocexamples">
SELECT DISTINCT Location
FROM Departmt
</cfquery>
</cffunction>
</cfcomponent>

Creating and Using Custom CFML Tags

You can extend CFML by creating and using custom CFML tags that encapsulate common code.
Creating custom tags
Custom tags let you extend CFML by adding your own tags to the ones supplied with ColdFusion. After you define a
custom tag, you can use it on a ColdFusion page just as you would any of the standard CFML tags, such as
and
.
cfoutput
You use custom tags to encapsulate your application logic so that it can be referenced from any ColdFusion page.
Custom tags allow for rapid application development and code reuse while offering off-the-shelf solutions for many
programming chores.
For example, you can create a custom tag, named
use that tag in a ColdFusion page, as follows:
<cf_happybirthday name="Ted Cantor" birthDate="December 5, 1987">
, to generate a birthday message. You could then
cf_happybirthday
Last updated 1/20/2012
208
cfquery

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents