What Are Advanced Custom Tags?


The last chapter reviewed how you can create and use Custom Tags to improve the maintainability of your code and increase your overall productivity. All of that will remain true during our discussion of advanced Custom Tags in this chapter.

The main reason to implement advanced Custom Tags is to increase functionality. The main programmatic difference between regular Custom Tags and advanced ones is that the latter utilize the ability to nest Custom Tags within each other. The nested Custom Tag architecture actually increases the power of Custom Tags because it allows them to interact with each other to better perform tasks.

To find good reasons for using nested Custom Tags, you don't have to look any further than the ColdFusion language itself. <cfhttp>, <cfquery>, <cfreport>, and <cfmail> all use nested tags, called <cfhttpparam>, <cfqueryparam>, <cfreportparam>, and <cfmailparam>, respectively.

<cfhttp> and <cfhttpparam> are discussed in Chapter 43, "Other Internet Protocols." <cfquery> is discussed in Chapter 7, "Using Databases," and <cfqueryparam> is discussed in Chapter 47, "Advanced Database Features." <cfmail> and <cfmailparam> are both introduced in Chapter 41, "Email Integration." <cfreport> and <cfreportparam> are both introduced in Chapter 19, "Reporting."


In each of these cases, the base or parent tag is completely functional on its own, but by adding the use of a subtag or child tag, the tag becomes even more powerful.

For instance, <cfhttp> by itself lets you create an HTTP call inside your ColdFusion template. By adding <cfhttpparam>, however, you can not only grab another Web page, but also post variables to it.

Alone, <cfquery> connects you to a data source. By adding <cfqueryparam>, you can perform data validation on the variables being passed to the SQL statement and declare the variable's data type.

<cfmail> also offers increased functionality through the use of its child tags. By itself, <cfmail> sends plain-text or HTML mail through an SMTP server. However, when you use <cfmailparam> in conjunction with <cfmail>, you can send one or more attachments with the email message.



Macromedia ColdFusion MX 7 Certified Developer Study Guide
Macromedia ColdFusion MX 7 Certified Developer Study Guide
ISBN: 0321330110
EAN: 2147483647
Year: 2004
Pages: 389
Authors: Ben Forta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net