where does a CFC get it's Application Scope
Asked Answered
E

2

5

I have a group of CFC's that I access from two seperate Applicaiton scopes.

One /Application.cfc is in the Root.

The other Application is in /Admin/Application.cfc The cfcs are in in /_cfc/

If I call a cfc (using createObject())from a page in (for example) /Admin/members/edit.cfm, does this cfc get it's Application scope from:

Application 1: /Application.cfc

or

Application 2: /Admin/Application.cfc

The calling page is under Application 2, but the CFC itself is under Application 1.

I hope I am making sense.

Thanks

Jason

Enterectomy answered 2/4, 2012 at 6:48 Comment(0)
P
12

Scopes are dependant on the context in which a cfc is instantiated and not its physical location.

So given your example a cfc that lives under Application1 instantiated from a template in Application2 will see the application scope from Application2

Pedal answered 2/4, 2012 at 7:18 Comment(0)
D
0

Application is dependant on the name. Thus if I had two applications with different names, thats 2 sets of application scope variables.

The name of the application is normally defined like this

<cfcomponent>
    <cfset this.name = 'myApplication' />
    ....
Draughty answered 2/4, 2012 at 7:3 Comment(1)
Thanks Dale. They both have different application names. That part is fine. I'm just wanting to confirm if a CFC get's it's application scope from the Application it physically sits under, or from the page that invoked it.Enterectomy

© 2022 - 2024 — McMap. All rights reserved.