I think the documentation meant that if:
1) you have an instance variable foo in the super class
2) you provide an accessor/mutator for it in the super class using the
"this" or "variables" notation.
3) you have the subclass declare and use an instance variable foo
thinking that it won't conflict with the super class' instance data.
4) you then call super.accessor() and you found out that you are pulling
the subclass' instance variable!
Another example:
cfcBase.cfc:
<cfcomponent displayname="The Base Class">
<cfparam name="instance" type="struct" default="#StructNew()#">
<cfset instance[GetCurrentTemplatePath()] = StructNew()>
<cfset instance[GetCurrentTemplatePath()].strBase = "This is the
Base Class' Instance Scoped strBase private member.">
<cffunction name="getstrBase" access="public"
returntype="string" displayname="Get instance.strBase" hint="returns the
value in instance.strBase">
<cfreturn instance[GetCurrentTemplatePath()].strBase>
</cffunction>
</cfcomponent>
cfcSub.cfc:
<cfcomponent extends="cfcBase" displayname="The Sub Class"
hint="Testing">
<cfparam name="instance" type="struct" default="#StructNew()#">
<cfset instance[GetCurrentTemplatePath()] = StructNew()>
<cfset instance[GetCurrentTemplatePath()].strBase = "Blah Blah">
<cffunction name="getstrBase" access="public"
returntype="string" displayname="Get instance.strBase" hint="This is for
the subclass.">
<cfreturn instance[GetCurrentTemplatePath()].strBase>
</cffunction>
<cffunction name="super_getstrBase" access="public"
returntype="string" displayname="Get super.instance.strBase" hint="This
is for the super class.">
<cfreturn super.getstrBase()>
</cffunction>
</cfcomponent>
test.cfm:
<cfobject name="oSub" component="cfcSub" />
<cfscript>
strSubBase = oSub.getstrBase();
strSuperBase = oSub.super_getstrBase();
</cfscript>
<cfoutput><xmp>
strSubBase == #strSubBase#
strSuperBase == #strSuperBase#
</xmp></cfoutput>
Yum.
Basically, there is ONLY one Variables space. The entire chain of
ancestor and descendent CFCs for a single instance of a descendant CFC
shares the same "namespace". Prior to MX, I have been using
Request[GetCurrentTemplatePath()] to create unique Request scope based
"persistent" memory space that would last an entire HTTP request. Hence,
multiple calls to the same custom tag does not need to re-execute the
same initializations or allocate more memory. :P
-----------------------
James Ang
Sr. Software Developer
MedSeek, Inc.
[EMAIL PROTECTED]
-----Original Message-----
From: Hardy Jonck [mailto:[EMAIL PROTECTED]
Sent: Saturday, September 27, 2003 12:45 PM
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] Top Ten Tips for Developing ColdFusion Components
Great Thanks
I was using the 'this' scope in many superclasses without any problems
-
and wondered what the documentation actually meant..
Hardy
----- Original Message -----
From: "Sean A Corfield" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, September 27, 2003 5:23 AM
Subject: Re: [CFCDev] Top Ten Tips for Developing ColdFusion Components
> On Friday, Sep 26, 2003, at 19:23 US/Pacific, Nathan Dintenfass wrote:
> > I believe the documentation in question is:
> >
> > http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/buildi46.htm
> >
> > "Note: If you use component inheritance, you cannot use the This
scope
> > in
> > the base (parent) component, only in the component that extends it."
>
> Hmm, that's a bit strange - to say the least. I've no idea what the
> documentation means since 'this' scope seems to work just fine with
> component inheritance... I'll ask the documentation team what's up
with
> this!
>
> Sean A Corfield -- http://www.corfield.org/blog/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]
>
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]