MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 246

Developing coldfusion mx applications
Table of Contents

Advertisement

Create a ColdFusion page with the following code, and save it as inherit.cfm in your web root
3
directory:
<cfinvoke component="corpQuery" method="getEmp" lastName="gilson">
<cfinvoke component="corpQuery" method="getLocalTime">
When you execute the inherit.cfm file, the
though it is invoked using the corpQuery component.
Using component.cfc
All CFCs automatically extend the ColdFusion WEB-INF\cftags\component.cfc component.
(WEB-INF is in the cf_root/wwwroot directory on ColdFusion configured with an embedded
J2EE server. It is in the cf_root directory when you deploy ColdFusion on a J2EE server.) This
CFC is distributed as a zero-length file. You can use it for any core methods or properties that you
want all CFCs in your ColdFusion application server instance to inherit.
Using the Super keyword
You use the Super keyword only on CFCs that use the Extends attribute to extend another CFC.
Unlike ColdFusion scopes, it is not used for variables; it is only used for CFC methods, and it is
not available on ColdFusion pages that invoke CFCs.
The Super keyword lets you refer to original, base component, versions of methods that the
current component extends. Therefore if CFC B extends CFC A, and CFC B overrides some of
the methods in CFC A, CFC B can use the original versions of the overridden methods, as
defined in CFC A, by prefixing the method name with Super.
For example, assume the following:
CFC B extends CFC A.
CFC A defines a Remove method that removes spaces from text.
CFC B defines a Replace method that removes invalid characters.
With these functions, in CFC B, you can invoke
replace invalid characters in your text. CFC B could call
Super.Replace(StringVar=Arguments.StringVar)
other invalid characters.
Included pages can use the Super keyword.
Super keyword limitations
The following limitations apply to the use of the Super keyword:
The Super keyword supports only one level of inheritance. If you use multiple levels of
inheritance, you can only use the Super keyword to access the current component's immediate
parent. For example, if C.cfc extends B.cfc and B.cfc extends A.cfc, you can use Super.myFunc
in C.cfc to invoke the version of myFunc that is defined in B.cfc. You cannot use
Super.Super.cfc to invoke the version of myFunc that is defined in A.cfc. To get around this
limitation, you could define a super_MyFunc method in B.cfc that invokes Super.myFunc.
The C.cfc could then invoke Super.super_MyFunc.
Because base components do not have access to the This scope, you cannot use the Super
keyword for any method that uses a variable in the This scope.
246
Chapter 11: Building and Using ColdFusion Components
component method executes even
getLocalTime
Replace(StringVar="some str%^ing")
to remove the spaces before removing
to

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion mx

Table of Contents