coldbox rc var not showing up

504 views Asked by At

ColdBox Variable

handlers/home.cfc

<cffunction name="index" output="false" hint="index">
    <cfargument name="event">
    <cfset rc.Test = 'This is a test 123.' />
    <cfset event.setView("home/index")>
</cffunction>

views/home/index.cfm

<cfdump var="#rc#" />

Why is rc.test not showing up in the dump?

2

There are 2 answers

0
Henry On

Without rc defined with cfargument, your rc.test will be set to variables.rc.test in your handler.

Do this:

<cffunction name="index" output="false" hint="index">
    <cfargument name="event">
    <cfargument name="rc">
    <cfargument name="prc">
    <cfset rc.Test = 'This is a test 123.' />
    <cfset event.setView("home/index")>
</cffunction>
0
rdaniels On

You need to assign RC to Event.getCollection(). We do this at the top of every handler function.

<cffunction name="index" returntype="void" output="false">
    <cfargument name="event" required="true">
    <cfscript>
        var rc = event.getCollection();
        var prc = event.getCollection( private = true );

        // your handler code here

        Event.setView('home/index');
    </cfscript>
</cffunction>