Using coldfusion components, About coldfusion components, Components panel overview (coldfusion) – Adobe Dreamweaver CC 2015 User Manual
Page 681
674
Building applications visually
Last updated 6/3/2015
More Help topics
Using ColdFusion components
Note: Support for ColdFusion is removed in Dreamweaver CC and later.
About ColdFusion components
ColdFusion component (CFC) files let you encapsulate application and business logic into self-contained, reusable
units. CFCs also provide a fast, easy way to create web services.
A CFC is a reusable software unit written in ColdFusion markup language (CFML), which makes it easy to reuse and
maintain your code.
You can use Dreamweaver to work with CFCs. For information on CFC tags and syntax, see the ColdFusion
documentation from within Dreamweaver (Help > Using ColdFusion).
Note: You can use CFCs only with ColdFusion MX or later. CFCs are not supported in ColdFusion 5.
CFCs are meant to provide a simple yet powerful way for developers to encapsulate elements of their websites.
Generally, you should use components for application or business logic. Use customs tags for presentation elements
such as customized greetings, dynamic menus, and so on.
As with many other types of construction, dynamic sites can often benefit from interchangeable parts. For example, a
dynamic site may run the same query repeatedly, or calculate the total price of shopping cart pages and recalculate it
every time an item is added. These tasks can be handled by components. You can fix, improve, extend, and even replace
a component with minimal impact to the rest of your application.
Suppose an online store calculates shipping charges based on the price of orders. For orders under $20, the shipping
charge is $4; for orders between $20 and $40, the shipping charge is $6, and so on. You could insert the logic for
calculating the shipping charge in both the shopping cart page and the checkout page, but that would mix HTML
presentation code and CFML logic code and generally make the code difficult to maintain and reuse.
You decide to create a CFC called Pricing that has, among other things, a function called ShippingCharge. The function
takes a price as an argument and returns a shipping charge. For example, if the value of the argument is 32.80, the
function returns 6.
In both the shopping cart page and the checkout page, you insert a special tag to invoke the ShippingCharge function.
When the page is requested, the function is invoked and a shipping charge is returned to the page.
Later, the store announces a special promotion: free shipping for all orders above $100. You make the change to the
shipping rates in one place—the ShippingCharge function of the Pricing component—and all the pages using the
function automatically get accurate shipping charges.
Components panel overview (ColdFusion)
Use the Components panel (Window > Components) to view and edit ColdFusion components, and add code in the
page that invokes the function when the CFM page is requested.