Discussion:
Need Help On Extending a CFC
(too old to reply)
Kapitaine
2009-03-27 13:07:27 UTC
Permalink
Hi,

If CFC "item" is initialised with an ID and every method in that CFC uses that
ID to filter certain things, how can I extend this "item" CFC in another CFC
called "ui" and still have access to its methods?

I am getting errors I think because what I want to extend is an initialised
VERSION of that "item" CFC based on an ID, where as using the
super.someFunction() in my "ui" CFC gives errors because presumably the methods
I am calling know nothing about its initialised self.

Is this making sense?

What is the best way to do this? Do I have to pass an entire initialised
version of the "item" CFC to the "ui" CFC as an argument? If so, how do I do
this?

Sorry about my confusing post, I am teaching myself some bits and I can't seem
to get my head around this.

Any help appreciated. Thanks,

Mikey.
Adam Cameron
2009-03-28 00:06:28 UTC
Permalink
Post by Kapitaine
If CFC "item" is initialised with an ID and every method in that CFC uses that
ID to filter certain things, how can I extend this "item" CFC in another CFC
called "ui" and still have access to its methods?
You don't have to do anything in particular, other than putting the EXTENDS
attribute in UI.cfc's <cfcomponent> tag, and the instantiate your object as
a type of UI instead of a type of item, eg:

o = createObject("component", "ui").init(/*whatever is necessary here*/);

Because UI.cfc extends item.cfc, it'll use the same init() method, unless
UI.cfc has one of its own, in which case you might want to consider calling
super.init() in that, at an appropriate point (usually first thing).
Post by Kapitaine
I am getting errors
It's hard to work out why you might be getting errors without seeing the
actual code and the actual error message...
--
Adam
Loading...