For the complete experience, please enable JavaScript in your browser. Thank you!

  • Creative Cloud
  • Photoshop
  • Illustrator
  • InDesign
  • Premiere Pro
  • After Effects
  • Lightroom
  • See all
  • See plans for: businesses photographers students
  • Document Cloud
  • Acrobat DC
  • eSign
  • Stock
  • Elements
  • Marketing Cloud
  • Analytics
  • Audience Manager
  • Campaign
  • Experience Manager
  • Media Optimizer
  • Target
  • See all
  • Acrobat Reader DC
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player
  • All products
  • Creative Cloud
  • Individuals
  • Photographers
  • Students and Teachers
  • Business
  • Schools and Universities
  • Marketing Cloud
  • Document Cloud
  • Stock
  • Elements
  • All products
  • Get Support
    Find answers quickly. Contact us if you need to.
    Start now >
  • Learn the apps
    Get started or learn new ways to work.
    Learn now >
  • Ask the community
    Post questions and get answers from experts.
    Start now >
    • About Us
    • Careers At Adobe
    • Investor Relations
    • Privacy  |  Security
    • Corporate Responsibility
    • Customer Showcase
    • Events
    • Contact Us
News
    • 3/22/2016
      Adobe Summit 2016: Are You An Experience Business?
    • 3/22/2016
      Adobe Announces Cross-Device Co-op to Enable People-Based Marketing
    • 3/22/2016
      Adobe and comScore Advance Digital TV and Ad Measurement
    • 3/22/2016
      Adobe Marketing Cloud Redefines TV Experience
Developing Applications Help / 

Import and new operations using cfimport

Adobe Community Help


Applies to

  • ColdFusion

Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 

CFScript supports import and new operations. "New" is now a keyword. However, it is not a reserved word, so you can use it as a variable name.
You can use the cfimport tag or import script operator to import a CFC. The import operation puts the contents of the specified component in the current name space, and caches the resolved component path in memory. The import action is effective on the current page only. If you import CFCs in Application.cfm, the CFC is not imported on other pages of the application. 
You refer to the imported component directly without using a dot-delimited pathname. Execution time for cached components is faster than with CFCs that you do not import.

Note: The cfobject and cfobject tags and the CreateObject function also cache the resolved component path. They do not, however, invoke an initializer function.

In script the import statement has the following syntax:

import "cfc_filepath"

Quotation marks are optional for most paths. Surround the path in quotation marks if any directory or the CFC name has a hyphen.
The cfimport tag now supports importing CFCs and takes a path attribute to specify the path to the CF file to import. 
Use the import function or cfimport tag with a path attribute on top of the page only. Using them elsewhere has the same effect as putting them on top of the page. Therefore, standard coding practice places the import tags or operators at the top of the file. The cfimport tag can precede a cfcomponent tag. The import CFScript statement must follow the component statement.
The ColdFusion Administrator Sever Settings > Caching page now has a Component Cache option, and a Clear Component Cache button. To prevent ColdFusion from caching resolved component paths, clear the Component Cache option. Click the Clear Component Cache button to remove any resolved component paths from the cache.

Note:

In all cases, ColdFusion automatically imports the com.adobe.coldfusion.* name space for CFCs. You do not have to import this path explicitly.

The new operator creates an instance of a CFC. It is equivalent to the cfobject tags and CreateObject function. You can use new as a CFScript operator, or in assignment statements outside a CFScript block, such as in a cfset tag. ColdFusion does not have a corresponding cfnew tag. 
The new operation has the following syntax:

cfObject=new cfcPath(constructorParam1,...)

or

cfObject=new cfcPath(arg1=constructorParam1Value,...)

If the folder name or CFC name has hyphen, use the following syntax:

cfObject=new "cfc-path"(constructorParam1,...)

If you use the import operator to import the directory that contains the CFC, the cfcPath value is the CFC filename. The constructor parameters can be positional or in name="value" format. When you use the new operator, ColdFusion does the following:

  1. Looks for an initmethod constructor method in the CFC. If found, ColdFusion instantiates the component and runs initmethod.
  2. If it does not find an initmethod constructor method, it looks for an init constructor method. If found, ColdFusion instantiates the component and runs initmethod.
  3. If neither method exists, the new operation instantiates the component but does not call a constructor.

Note:

Only the new operator automatically invokes the initmethod or init function. The new operator returns the value returned by init or initmethod and if the return is void it returns the instance of the CFC. The cfobject tags and the CreateObject function do not invoke the function and you must explicitly call any custom initialization code.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy

Choose your region United States (Change)   Products   Downloads   Learn & Support   Company
Choose your region Close

Americas

Europe, Middle East and Africa

Asia Pacific

  • Brasil
  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Cyprus - English
  • Česká republika
  • Danmark
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Greece - English
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • Malta - English
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • Southeast Asia (Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam) - English
  • 台灣

Commonwealth of Independent States

  • Includes Armenia, Azerbaijan, Belarus, Georgia, Moldova, Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Ukraine, Uzbekistan

Copyright © 2016 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

AdChoices