On Sunday, Mar 30, 2003, at 09:37 US/Pacific, Todd wrote:
I have a question on this, sorry if it's dumb and not necessarily in this exact topic mentioned below, but it somewhat is ... since I'm playing around with the instance/setter/getter,etc... Say you have user.cfc and that is persisting via session variable. If user.cfc EXTENDS another CFC, how come that doesn't persist as well? What is extends actually doing? Is that nothing more than opening a communication bridge to the extended object?

I don't quite understand your question so a couple of clarifications:


You say "persisting via session variable". Do you mean something like:

<cfset session.user = createObject("component","user")>

If user.cfc extends another CFC (say baseuser.cfc), you ask "how come that doesn't persist as well?" I'm not sure what you mean here.

If user.cfc extends baseuser.cfc, then when you create an instance of user.cfc, it's almost as if you've automatically created an instance of baseuser.cfc and stored it inside the instance of user.cfc. If you store that instance of user.cfc in session scope, any data used in the baseuser.cfc instance that it extends is also in session scope.

You can use <cfdump> to see how a base component becomes part of a component that extends it:

        <cfcomponent displayname="base.cfc">
                <cffunction name="foo">
                        <cfset this.baseValue = "Hello">
                </cffunction>
        <cfcomponent>

        <cfcomponent displayname="derived.cfc" extends="base">
                <cffunction name="bar">
                        <cfset this.derivedValue = "Derived">
                </cffunction>
        </cfcomponent>

test.cfm:
        <cfset obj = createObject("component","derived")>
        <cfset obj.foo()>
        <cfset obj.bar()>
        <cfdump var="#obj#">

Note how both 'foo()' and 'bar()' are available in the derived object. Note also, when you dump the derived object that 'baseValue' and 'derivedValue' can be seen in the object (only "this" scope values get dumped, not any non-public instance data - so I used "this" scope here just for illustration).

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).

Reply via email to