Home
Username:
Password:
Macromedia ColdFusion MX Tutorials

More Component Functionality / Packaging and CF Mapping




Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com’s entire library of video tutorials.


Learn More

Subtitles of the Movie

Most developers will find it useful to store related components in a single directory. This is called packaging in object oriented terms, and allows developers to manage the interaction of components in a broader sense. Packages in Cold Fusion correspond to directories. So for example our "Where's Tom" components stored in the admin directory, are in one package and the components stored in the dirPackage directory are in another package. When a component references another component without specifying a path, Cold Fusion looks first in the same directory as the original component. This can be useful for storing code organized into applications because you can have components with the same name but different code as long as they are in different directories. For example we could copy our meal.cfc component from the dirPackage directory to the admin directory. Then we could change the review in the eat method. Now we can call the eat function in the meal activity components, order lunch method. First we'll create a meal object, and reference the component with just the word meal, to the meal object method called eat, which requires that food be passed into it. Now if we go to our inherited.cfm page, we can create an object called Tom's meal from the meal activity component, then we can set the meal review, as the order lunch method of Tom's meal. Then, we can output the value of meal review, which is an object, an object returned from the order lunch function in the meal activity component. When we browse to this page, we can see the output of our meal review with the correct review. It can be useful to set up a mapping in Cold Fusion administrator for a component package. This way you can reference components using a single step off the root. To set this up open Cold Fusion administrator. Under server settings, click on mappings. We'll map our dirPackage directory to /com. Next click browse server and select the wherestom_working/dirPackage directory and click apply. Then click update mapping and we'll see our new mapping at the bottom of our list. Now, if we go to our taste test page, we can change the reference to these components to com, And when we browse to this page Cold Fusion has located the components with a much easier reference. This can also be helpful if you aren't sure, as you are working on your application, exactly what your final directory structure will be, since they would only need to be changed in one place. your final directory structure will be, since they would only need to be changed in one place.

Tutorial Information

Course: Macromedia ColdFusion MX
Author: Darcey Spears
SKU: 33474
ISBN: 1932072772
Release Date: 2004-03-05
Duration: 6.5 hrs / 102 lessons
Work Files: Yes
Captions: For Online University members only
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 98,729 Video Tutorials (23,265 free)
  • Video Available as Flash or QuickTime
  • Over 1026 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available