Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Need Help On Extending a CFC

Engaged ,
Mar 27, 2009 Mar 27, 2009
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.
252
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 27, 2009 Mar 27, 2009
LATEST
> 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).


> 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources