OpenBD / openbd-core

The original open source Java powered GPL CFML runtime engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get struct/arrays from cfml in cfscript javascript

matthewroach opened this issue · comments

When using $cf.get() to get a CFML variable within cfscript javascript it does not translate. See below example, setting and dumping the same struct in cfscript and cfscript javascript are the same output, but if I wanted to get access to the cfscript variable in cfscirpt javascript it does not translate it.

Am I getting the variable correctly?

<cfscript>

    testCFML = {
        items: [
            { name: 'Matthew' },
            { name: 'Alice' }
        ]
    };

    writeDump(testCFML);

</cfscript>

<p>cfscript javascript</p>

<cfscript language="javascript">

    var test = {
        items: [
            { name: 'Matthew' },
            { name: 'Alice' }
        ]
    };

    $cf.writeDump(test);

    print('<hr />');

    var testFromCFML = $cf.get('testCFML')
    $cf.writeDump(testFromCFML);

</cfscript>

screenshot from 2015-11-27 08 59 56

It looks like the data is indeed there, but when you send it back for use with the writedump, it ends up dumping the metadata about the js java object instead of the data you pass.

I created a dump() method for use within cfscript javascript to achieve the data dump.

I think this can be closed, unless anyone objects?