This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

MisterDai

By: a guest on Oct 8th, 2009  |  syntax: ColdFusion  |  size: 1.25 KB  |  views: 347  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!--- Function for undoing anything that CfHtmlHead intends to do --->
  2. <cffunction name="resetCFHtmlHead" output="false" returntype="void">
  3.         <cfscript>
  4.                 var local = StructNew();
  5.                 local.out = getPageContext().getOut();
  6.                 while (getMetaData(local.out).getName() Is 'coldfusion.runtime.NeoBodyContent') {
  7.                         local.out = local.out.getEnclosingWriter();
  8.                 }
  9.                 local.method = local.out.getClass().getDeclaredMethod('initHeaderBuffer', ArrayNew(1));
  10.                 local.method.setAccessible(true);
  11.                 local.method.invoke(local.out, ArrayNew(1));
  12.         </cfscript>
  13. </cffunction>
  14.  
  15. <!--- Function for retrieving anything that CfHtmlHead intends to do --->
  16. <cffunction name="getCFHtmlHead" output="false" returntype="any">
  17.         <cfscript>
  18.                 var local = StructNew();
  19.                 local.out = getPageContext().getOut();
  20.                 while (getMetaData(local.out).getName() Is 'coldfusion.runtime.NeoBodyContent') {
  21.                         local.out = local.out.getEnclosingWriter();
  22.                 }
  23.                 local.field = local.out.getClass().getDeclaredField("headerBuffer");
  24.                 local.buffer = 0;
  25.                 local.field.setAccessible(true);
  26.                 local.buffer = local.field.get(local.out);
  27.                 /* The get might return null */
  28.                 if (StructKeyExists(local, 'buffer')) {
  29.                         return local.buffer.toString();
  30.                 } else {
  31.                         return '';
  32.                 }
  33.         </cfscript>
  34. </cffunction>
clone this paste RAW Paste Data