Visually Creating A Component In Dreamweaver - MACROMEDIA DREAMWEAVER MX 2004-USING DREAMWEAVER Use Manual

Hide thumbs Also See for DREAMWEAVER MX 2004-USING DREAMWEAVER:
Table of Contents

Advertisement

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 ColdFusion component called Pricing that has, among other things, a
function called
ShippingCharge
shipping charge. For example, if the value of the argument is 32.80, then the function returns 6.
In both the shopping cart page and the checkout page, you insert a special tag to invoke the
ShippingCharge
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
component—and all the pages using the function automatically get accurate shipping charges.

Visually creating a component in Dreamweaver

You can use Dreamweaver to visually define a ColdFusion component and its functions.
Dreamweaver creates a .cfc file and inserts the necessary CFML tags for you.
Note: Depending on the component, you may have to complete some code by hand.
To create a ColdFusion component visually:
Open a ColdFusion page in Dreamweaver.
1
In the Components panel (Window > Components), select CF Components from the
2
pop-up menu.
On the Components panel, click the Plus (+) button.
3
The Create Component dialog box opens.
Complete the dialog box and click OK.
4
For more information, click the Help button in the dialog box.
Dreamweaver writes a .cfc file and saves it in the folder you specified. The new component also
appears in the Components panel (after clicking Refresh).
To remove a component, you must delete the .cfc file manually from the server.
Related topics
"About ColdFusion components" on page 573
"Editing ColdFusion components in Dreamweaver" on page 576
"Building web pages that use ColdFusion components" on page 577
574
Chapter 36: Using ColdFusion Components
. The function takes a price as an argument and returns a
function. When the page is requested, the function is invoked and a shipping
function of the Pricing
ShippingCharge

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the DREAMWEAVER MX 2004-USING DREAMWEAVER and is the answer not in the manual?

This manual is also suitable for:

Dreamweaver mx 2004

Table of Contents