Scope not working outside of the CFC folder for Session scope

417 views Asked by At

I recently installed ColdFusion 2018 at work and have been frustrated by the inability to get scope working correctly. As usual I put all my .cfcs into the /CFC folder, and none of them will execute without a blank application.cfm file in that folder. I have tried extending application, including application, proxy extending application, moving the CFCs to the root folder only gets me syntax error on JSON. I have read every article that I can find for the past two weeks and I am still unable to understand why scope will not work. It seems I can set session variables within the /CFC folder, but they are not available outside the folder? I have not worked with CF for a few years, but consider myself versed, and for the life of me cannot get this working. its probable that I am missing the forest due to trees, but if anyone would be willing to assist, I would be grateful.

instantiated object;

application.SessionMgr = CreateObject(this.obj,'CFC.SessionMgr').init('session');

proxy call;

cfajaxproxy cfc="CFC/SessionMgr"       jsclassname="SessionMgr";

return is correct;

var s = new SessionMgr();
       var setReport = s.setValue('ReportID', document.getElementById('cboReportKey').value);
       alert(setReport);

however even manually setting session.ReportID = 7 will not persist outside the folder.

here is the SessionMgr.init

this is the init;

<cffunction name="init" access="public" returntype="SessionMgr" output="no" hint="I instantiate and return this object.">
        <cfargument name="scope" type="string" required="yes">
        <cfargument name="requestvar" type="string" default="SessionInfo">
            <cfset var scopes = "application,Client,Session">
            <cfif Not ListFindNoCase(scopes, arguments.scope)>
                <cfthrow message="The scope argument for SessionMgr must be a valid scope (#scopes#)." type="MethodErr">
            </cfif>
            <cfset variables.scope = arguments.scope>
            <cfset variables.requestvar = arguments.requestvar>
            <cfset updateRequestVar()>
        <cfreturn this>
    </cffunction>

and the setValue fn

<cffunction name="setValue" access="remote"  hint="I set the value of the given user-specific variable." returntype="string">
        <cfargument name="variablename" type="string" required="yes">
        <cfargument name="value" type="any" required="yes">
            <cfset var val = arguments.value />
            <cfset SetVariable("#arguments.variablename#", val) />
            <cfset r =  Evaluate(arguments.variablename) />
        <cfreturn r />
    </cffunction>
1

There are 1 answers

6
BigBear On

ok, after trying everything, heres the solution. extending by proxy doesnt work for this situation, tried that. What finally worked was creating an application.cfc IN the /CFC folder and stripping out all functional components from the /root application.cfc and simply ensuring the application name was the same in the stripped down version in /CFC folder as the /root cfc name. This apparently psuedo extends all the functionality from the /root application.cfc and makes everything available to the framework in the /CFC folder. Thanks to everyone here helping to get me to think outside my wheelhouse and resolving this issue.