Skip to main content
Participating Frequently
December 20, 2007
Question

Multiple level inheritance

  • December 20, 2007
  • 2 replies
  • 372 views
i've got 3 cfcs: a, b, and c.

<cfcomponent name="a">
<cffunction name="Init" access="public" returntype="a">
<cfreturn this />
</cffunction>
</cfcompnonent>

<cfcomponent name="b" extends="a">
...
</cfcompnonent>

<cfcomponent name="c" extends="b">
...
</cfcompnonent>

I then try to call:
bobo = CreateObject("Component", "c").Init();

But i'm getting "The value returned from the Init function is not of type a".

Any Ideas?

Should i have b and c override the init() method and thier version call each that one's base super or something?
This topic has been closed for replies.

2 replies

Inspiring
December 20, 2007
> Yep, that was exactly what i needed to do.

No, you should not / do not need to do that.

I think if you tested with your exact(*) test code, then it would all work
fine. I have just tested this.

However I reckon your sample code is just a simplification of the code you
have erroring, and the problem is something peculiar to the rest of the
code that you've factored out.

Post the exact code.

Which version of CF are you running?

--
Adam

(*) Allowing for correcting the typos (your closing </cfcompnonent> (sic)
tag). Also <cfcomponent> has no NAME attribute, so you should lose that.
It doesn't generally cause problems as <cfcomponent> will allow any
nonsense attributes, but I believe some people have had some strife when
calling CFC instances remotely with a NAME attribute.
Jim-samaAuthor
Participating Frequently
December 20, 2007
Yep, that was exactly what i needed to do.