CURRENT PROJECTS
loading
CATEGORIES AND POSTS
loading
overset
DEVELOPMENT LOG FOR JIM PALMER
Posted 01/31/2007 in coldfusion


To go on my other article, I added two lines to my onRequestEnd function as set in the Application.cfc. These lines will parse out preceding and trailing whitespace for all CFAJAX responses if your CF server is still having trouble doing proper "whitespace management".
<cffunction name="onRequestEnd" output="Yes"><cfsetting enablecfoutputonly="Yes">
	<!--- forceful strip of whitespaces from CFMX Java output buffer - idea thanks to Dmitry Namiot --->
	<cfset pageContent = getPageContext().getOut().getString()>
	<cfset getPageContext().getOut().clearBuffer()>
	<!--- AJAX whitespace stripping --->
	<cfset pageContent = REReplace(pageContent, "^[[:space:]]+\*\*\*\*\/", " ****/", "all" )>
	<cfset pageContent = REReplace(pageContent, "\*\/[[:space:]]+$", "*/", "all" )>
	<cfset pageContent = REReplace(pageContent, "^[[:space:]]+<", "<", "all" )>
	<cfset pageContent = REReplace(pageContent, ">[[:space:]]+$", ">", "all" )>
	<!--- capture pure whitespace pages for those CFLOCATION tags in the middle of a logic block --->
	<cfset pageContent = REReplace(pageContent, "^[[:space:]]+$", "", "all" )>
	<cfset writeOutput(pageContent)>
	<cfset getPageContext().getOut().flush()>
<cfsetting enablecfoutputonly="No"></cffunction>
comments
loading
new comment
NAME
EMAIL ME ON UPDATES
EMAIL (hidden)
URL
MESSAGE TAGS ALLOWED: <code> <a> <pre class="code [tab4|tabX|inline|bash]"> <br>
PREVIEW COMMENT
TURING TEST
gravatar