::   faq

Questions

  1. What are CFCs?
  2. What is method overloading?
  3. Does CFMX support method overloading in CFCs?
  4. What is method overriding?
  5. Do CFCs have constructors?
  6. Do CFCs support inheritance?
  7. What is the advantage of using a CFC to encapsulate data versus a Structure?
  8. How can I expose my CFC methods to Flash but not general Internet consumption?
  9. How can I specify the port name for my CFC's web service description?
  10. Is Application.cfm called when invoking a CFC?






  1. What are CFCs?
    CFCs are ColdFusion Components. They are new in ColdFusion MX, and provide a way for developing ColdFusion applications using an object-oriented approach.
    -Rob Brooks-Bilson  



  2. What is method overloading?
    You overload a method when you call an object that has more than one method with the same name. Each like named method must have a different method signature. A method signature is determined by the number and type of parameters the method accepts as well as its return type.



  3. Does CFMX support method overloading in CFCs?
    No. ColdFusion MX does not support method overloading in CFCs. CFMX does, however, support method overriding.
    -Rob Brooks-Bilson  



  4. What is method overriding?
    ColdFusion MX supports method overriding when one component extends another component that contains a like named method. In this case, the method of the subcomponent overrides the like named method in the base component.



  5. Do CFCs have constructors?
    Yes and No. Not in the sense that Java does, where a constructor is used to instantiate the object. However, in CFCs, any code you place in the component body, outside of a method, is automatically executed whenever the component is instantiated. This provides some of the functionality typically associated with a constructor, however, it is not synonymous (although you will frequently hear this code referred to as constructor code).
    -Rob Brooks-Bilson  



  6. Do CFCs support inheritance?
    Yes. CFCs support limited inheritance via the EXTENDS attribute in the CFCOMPONENT tag. When one CFC extends another, it automatically inherits all of that CFC's variables, properties, and methods (and the properties and methods of any CFC's it extends). If you have a method in the CFC doing the extending, it automatically overwrites any like named methods in the inherited CFCs.
    -Rob Brooks-Bilson  



  7. What is the advantage of using a CFC to encapsulate data versus a Structure?
    When comparing the usage of a CFC for data encapsulation versus a Structure, we are primarily referring to CFC's that use the CFPROPERTY tag to create pre-defined properties. By using the CFPROPERTY tag developers writing code that will use the component will have automatic documentation regarding the properties (keys) the component should contain and their types. In contrast, if you have a function that returns a structure, the developer who utilizes your function must rely on your documentation to know what keys exist in the structure and the type of data they contain.

    This is particularly important with Web Services. When a web service consumer looks at the web service description (WSDL) for your service, a method that returns a structure simply tells them that you are returning a map of key/value pairs. Since much of the work in consuming a web service is provided by the client environment, such as ColdFusion or .NET, this client environment must understand the type of data being returned. Structure maps are not understood in all platforms and causes web services to lose cross-platform interoperability. In contrast, a web service that returns a CFC with pre-defined properties will have a fully descriptive WSDL with enough information to be consumed in most client environments.

    -Samuel R. Neff  



  8. How can I expose my CFC methods to Flash but not general Internet consumption?
    Specify access="remote" but don't specify a returnType.
    -Samuel R. Neff  



  9. How can I specify the port name for my CFC's web service description?
    There is no built in mechanism for customizing a WSDL in this way within CFMX. However, developers who need to customize their WSDL have a few options:


    • View the WSDL within a browser and save it to a file. Manually modify the file as necessary. Put the file in your web directory, preferably the same directory as the component, and point users to that file instead of to the component. This method is the easiest to implement but provides for maintenance problems since the file needs to be recreated each time the CFC definition is modified.
    • Add a method to your CFC called "wsdl". Specify returnType="void" and output="true". Use CFHTTP to grab the automatic WSDL for your CFC and then XML processing to modify it as necessary. Then output the WSDL to the user. Point users to your CFC method http://yourhost.com/yourComponent.cfc?method=wsdl to generate a WSDL. Caching can be implemented to improve performance, as is done by ColdFusion. You can also take advantage of inheritance and create a top level component that includes this method and extend that component for all others.

    Note that some modifications to the WSDL can cause the service not to function. However, some modifications are necessary for interoperability with other platforms.

    -Samuel R. Neff  



  10. Is Application.cfm called when invoking a CFC?
    When calling a CFC from Flash Remoting or as a Web Service, the Application.cfm is executed prior to instantiating the component and calling the requested method. The same rules regarding directory location apply to components as apply to standard templates.

    When calling a CFC from another local ColdFusion template, the component's Application.cfm is not executed since the Application.cfm applicable to the calling template was already executed.

    Developers need to be careful with Application.cfm files when creating CFCs, that will be utilized for Flash Remoting or as a Web Service. If CFC's are placed in a directory along with standard templates for an application, or a subdirectory, the Application.cfm file can not contain any code that assumes the call is from an interactive user for an HTML page. Actions such as checking for a logged-in session must be avoided.

    -Samuel R. Neff  



Latest CFCs
- regressionCFC
- makeAShorterLink
- tinyURL
- scriptEncode
- CF Admin Mappings
- Transliterator
- i18nCurrency
- i18nSort
- javaRBCFC
- tmt_java_regexp
- tmt_java_string
- debugIP
- CFC Explorer with Usage
- timeZone
- dumpCFC
- geoLocator
- i18nCFC
- uBlocks
- AdBanner

Top Five Downloads
- Coming soon
- Coming soon
- Coming soon
- Coming soon
- Coming soon