Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I retrieve the current value of enablecfoutputonly?

We are using Coldfusion 9.

Is there a simple way to know if enablecfoutputonly has been set to true during a particular request?

like image 786
Tom Hubbard Avatar asked Nov 12 '12 22:11

Tom Hubbard


1 Answers

I cannot test with CF9 right now, but in CF10 it is accessible from getPageContext() by checking the output object:

<cfscript>
   out = getPageContext().getOut();
   // Is the cfsetting enablecfoutputonly value currently true?
   isSettingEnabled = out.getDisableCount() >  0;
   WriteOutput("isSettingEnabled="& isSettingEnabled &"<br>");
   // Is output currently allowed?
   isOuputtingEnabled = out.getDisableCount() == 0 || out.getOutputCount() > 0;
   WriteOutput("isOuputtingEnabled="& isOuputtingEnabled &"<br>");
</cfscript>

.. or using reflection:

<cfscript>
    out = getPageContext().getOut();
    internalMethod = out.getClass().getDeclaredMethod("isOutputEnabled", []);
    internalMethod.setAccessible( true );
    isOuputtingEnabled = internalMethod.invoke( out, [] );
   // is output currently allowed?
    WriteOutput("isOuputtingEnabled="& isOuputtingEnabled);
</cfscript>
like image 196
Leigh Avatar answered Nov 09 '22 16:11

Leigh