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

Passing a cfc object to another cfc

Guest
Sep 23, 2009 Sep 23, 2009

Hi,

I am relatively new to using cfc, so I am not sure if what I am asking for is possible:

Can I pass a CFC object (that has been instantiated) to another CFC?  For example, I instantiate a CFC object

<cfobject component="CFC1" name="myCFC1Obj">
<cfset myCFC1Obj.init('abc')>

Now I want to instantiate a second CFC object

<cfobject component="CFC2" name="myCFC2Obj">

I would like the functions in myCFC2Obj to have access to myCFC1Obj variables
and functions, either by passing myCFC1Obj as a function argument or by
using myCFC1Obj to instantiate myCFC2Obj.

I have read http://forums.adobe.com/message/1894989#1894989, but this
deals with instantiating CFC1 object inside CFC2.  What I want is to instantiate
CFC1 object outside and pass it to CFC2.

Would I be able to do this?

Thank you.



TOPICS
Getting started
758
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

correct answers 1 Correct answer

LEGEND , Sep 23, 2009 Sep 23, 2009

An CFC instance (object) is just a variable like any other variable.  So there's no trick to passing it into a function as an argument, you just do it as you would with any other value.

In your <cfargument> tag, if you're wont to specify the TYPE attribute, it needs to be the CFC name or path (I use path).  That's the only real special consideration.

--

Adam

Translate
LEGEND ,
Sep 23, 2009 Sep 23, 2009

An CFC instance (object) is just a variable like any other variable.  So there's no trick to passing it into a function as an argument, you just do it as you would with any other value.

In your <cfargument> tag, if you're wont to specify the TYPE attribute, it needs to be the CFC name or path (I use path).  That's the only real special consideration.

--

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
Guest
Sep 24, 2009 Sep 24, 2009
LATEST

Hi Adam,

Thanks for your answer.  I wasn't aware that you can just pass a CFC object just like a normal variable.

Regards,

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