Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CFdump cfcomponent cfscript

Tags:

coldfusion

Can one use cfdump inside a cfcomponent? Can one use cfdump inside a cfscript?

I know the anser is no then how can one emit the values of the functions insde cfcomponent cfscript? I am using CF8

like image 960
Zill Avatar asked Dec 16 '09 21:12

Zill


4 Answers

Can one use cfdump inside a cfcomponent?

Yes, with some caveats. If you use a CFDUMP followed by CFABORT, the dump will be displayed whether or not the component/method has output turned off. That does, of course, abort all processing.

Can one use cfdump inside a cfscript?

Not exactly (unless you're using CF9), but there are workarounds.

You can close your script, put in the dump tag, then re-open it, like so:

</cfscript><cfdump var="#myVar#"><cfscript>

There is also a UDF at CFLib that mimics the CFDUMP tag.

Dump

Added: In CF9 or later, there is also writeDump().

like image 109
ale Avatar answered Nov 06 '22 17:11

ale


Coldfusion 9:

<cfscript>
    myVar = "this is a test";
    WriteDump(myVar); 
</cfscript>

Coldfusion 8 and below: CF 8 does not have a cfscript version of the tag, so if needed, it needs to be abstracted into a user defined function first. This function will need to be accessible to your component.

I avoided the name "WriteDump()" to prevent any possible conflict if this code is used with CF9.

<!--- Abstract cfdump tag for use in cfscript --->
<cffunction name="scriptDump" output="no" hint="Abstracts cfdump for cfscript">
    <cfargument name="myVar" required="yes">
    <cfset var result = "">

    <cfsavecontent variable="result">
        <cfdump var="#arguments.myVar#">
    </cfsavecontent>

    <cfreturn result>
</cffunction>

<cfset myVar = "this is a test">

<!--- Test the scriptDump(var) function in cfscript --->
<cfscript>
    dumpOfMyVar = scriptDump(myVar);
</cfscript>

<!--- Test the scriptDump(var) function in regular HTML --->
<cfoutput>
    #scriptDump(myVar)#
</cfoutput>
like image 31
Dan Sorensen Avatar answered Nov 06 '22 15:11

Dan Sorensen


cfdump inside cfcomponent? why not... But I think you should do it in a cffunction.

cfdump inside cfscript? WriteDump() in CF9, or search cflib for a UDF that works in CF6+

like image 1
Henry Avatar answered Nov 06 '22 15:11

Henry


You can only use writeDump in CF9. If you're in CF8, use this:


adminapi = createObject("component","cfide.adminapi.base");
adminapi.dump(foo);
like image 1
Travis Heeter Avatar answered Nov 06 '22 17:11

Travis Heeter