I was playing around with a little something today when I ran across a bug. If you try to use cfajaxproxy and bind a textarea to a JavaScript function, you will get an error if the textarea contains a newline. Consider:
<cfajaxproxy bind="javascript:setCount({body2@keyup})">
<script>
function setCount(r) {
var cdiv = document.getElementById('counter');
cdiv.innerHTML = cdiv.innerHTML + 'you did it' + r + '<br>';
}
</script>
<cfform name="ray">
<cftextarea id="body2" name="body2"></cftextarea>
</cfform>
<div id="counter"></div>
Turns out the newline breaks the JavaScript call. If you switch to a CFC call it works fine, but for what I was doing, I didn't need to call the server. Todd pointed out that this is rather trivial code, I could have just done this:
<cftextarea id="body2" name="body2" onkeyup="javascript:setCount(this.value);"></cftextarea>
But I wanted to keep it inside cfajaxproxy. I'll report a bug on this in a few minutes.
Archived Comments
cfajaxproxy has one more important bug in dealing with symbolic links. you are forced to put the cfc's in wwwroot folder if your default application is based on symbolic links. Adobe has recorded it as bug but and this will also be resolved soon.
vishy
Ray,
The newline bug which you have reported has already been fixed. But it is just that it could not make it into the first hot fix.
I just applied hotfix 2 and it does not mention a fix for the issue of newlines and cfajaxproxy. In addition, I am still experiencing the issue.
Be patient. I know for a fact this bug is logged with Adobe. I'm sure the next update will have the fix.
I suppose I should clarify a little more. I am including a fairly simple example of code from a file named test.cfm that shows the bug in CFAJAXPROXY:
<cfif IsDefined("form.user_comment")>
<cfset request.textarea_field_value = form.user_comment>
<cfelse>
<cfset request.textarea_field_value = "">
</cfif>
<cfif IsDefined("url.call_cfajaxproxy")>
<cfset request.call_cfajaxproxy = url.call_cfajaxproxy>
<cfelse>
<cfif IsDefined("form.call_cfajaxproxy")>
<cfset request.call_cfajaxproxy = form.call_cfajaxproxy>
<cfelse>
<cfset request.call_cfajaxproxy = "N">
</cfif>
</cfif>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1...">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<SCRIPT LANGUAGE="JavaScript2.0" TYPE="text/javascript">
function jsf_test() {var jsv_just_testing = 1;}
</SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CFAJAXPROXY BUG</title>
</head>
<body>
This was tested with an Internet Explorer 7 browser on WinXP and shows that CFAJAXPROXY has a bug in it related to new lines in textarea
fields. You can make the "Unterminated string constant" error occur by donig the following:
<ol>
<li>Enter "1" followed by the Enter key to created a newline</li>
<li>Enter "2" on the new line</li>
<li>Click the Submit button</li>
<li>
<cfif request.call_cfajaxproxy EQ "Y">
Still think this is not a problem with CFAJAXPROXY?
<a href="test.cfm?call_cfajaxproxy=N">Click here</a> to try <strong>without</strong> the call to cfajaxproxy.
<cfelse>
<a href="test.cfm?call_cfajaxproxy=Y">Click here</a> to try <strong>with</strong> the call to cfajaxproxy.
</cfif>
</li>
</ol>
<cfif IsDefined("form.user_comment")>
Values posted at <cfoutput>#TimeFormat(now(),"h:mm:ss tt")#</cfoutput>
</cfif>
<CFFORM ACTION="test.cfm" METHOD="POST" id="testit" name="test_form">
<TEXTAREA NAME="user_comment" COLS="50" ROWS="10"><cfoutput>#request.textarea_field_value#</cfoutput>
Um - not sure why you need to clarify. It is _definitely_ a bug, and Adobe _definitely_ has it reported. :)
Sorry, I didn't see your reply before I clarified. Thanks for the information.
I just installed HOTFIX 3 and it is still a problem. There is also nothing in the HOTFIX 3 release notes that indicates it was fixed.
http://kb.adobe.com/selfser...
It will be. I know it's recorded. Don't forget Adobe is working on an update. Not a hotfix, but an update.