Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Building ColdFusion components > Structuring and reusing code Using component packages PreviousNext

Using component packages

Components stored in the same directory are members of a component package. Component packages help prevent naming conflicts and facilitate easy component deployment. For example:

To invoke a packaged component method using the cfinvoke tag:

  1. In your web root directory, create a directory named appResources.
  2. In the appResources directory, create a directory named components.
  3. Move the tellTime.cfc and getUTCTime.cfm files that you created in the Defining component methods section to the components directory.
  4. Create a ColdFusion page with the following content and save it in your web root as timeDisplay.cfm:
    <h3>Time Display Page</h3>
    <b>Server's Local Time:</b>
    <cfinvoke component="appResources.components.tellTime"
    method="getLocalTime"><br> <b>Calculated UTC Time:</b> <cfinvoke component="appResources.components.tellTime"
    method="getUTCTime">

    You use dot syntax to navigate directory structures. Place the directory name before the component name.

The following example shows a CFScript invocation:

<cfscript>
helloCFC = createObject("component", "appResources.components.catQuery");
helloCFC.getSaleItems();
</cfscript>

The following example shows a URL invocation:

http://localhost/appResources/components/catQuery.cfc?method=getSalesItems

Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Building ColdFusion components > Structuring and reusing code Using component packages PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/buildi53.htm