Mar 31 2009
I just ran into another goofy Ajax problem with my ColdFusion apps. I have a page using a bound cfdiv to load a form. The form, once submitted, is supposed to take the value of a form field entered on the page and run an AjaxOnLoad event to use that value elsewhere. Here's a simple test to show what I mean.
First, create the main page, test.cfm:
<cfsilent>
<cfajaximport tags="cfform" />
</cfsilent>
<html>
<head></head>
<body>
<cfdiv bind="url:form.cfm" />
</body></html>
Now in form.cfm, add the following code:
<cfset myvar = 2 />
<cfif IsDefined("FORM.fieldnames")>
<cfset myvar = FORM.testfield />
<cfset ajaxOnLoad("testFunction") />
</cfif>
<cfoutput>
<script type="text/javascript">
testFunction = function(){
alert('#myvar#');
}
</script>
</cfoutput>
<cfform>
<cfinput name="testfield" value="#myvar#" />
<cfinput type="submit" name="submitbutton" value="Submit Test" />
</cfform>
When you submit the form, you'll get the value 2 alerted. I thought I would try to be sneaky and add an if statement around the script so that it was only output when the value wasn't 2, like so:
<cfset myvar = 2 />
<cfif IsDefined("FORM.fieldnames")>
<cfset myvar = FORM.testfield />
<cfset ajaxOnLoad("testFunction") />
</cfif>
<cfif myVar NEQ 2>
<cfoutput>
<script type="text/javascript">
testFunction = function(){
alert('#myvar#');
}
</script>
</cfoutput>
</cfif>
<cfform>
<cfinput name="testfield" value="#myvar#" />
<cfinput type="submit" name="submitbutton" value="Submit Test" />
</cfform>
That just caused a javascript error that it couldn't find the testFunction script. So this tells me that the script is rendered to the page when the div is first loaded, and it's not updated on subsequent div reloads. So my way around this is to put the new value into a hidden form field, and then use ColdFusion.getElementValue() to pick up the value for my testFunction.
Hope this saves someone else some frustration.
Mar 26 2009
This is more for myself than anyone else, but I hit an odd snag in ColdFusion this morning. I got an error when trying to create a new structure member using a CreateUUID() function and ColdFusion's shorthand structure notation. The following code fails:
<cfset CurrentOrder.Cart[CreateUUID()] = {type = "foo"} />
The error I receive is that "Element 435A2A8C-0B35-C81F-4F36BE50E1B8F394 is undefined in a CFML structure referenced as part of an expression." Well duh! I'm trying to create it!
So I changed the code to this, which works perfectly:
<cfset myvar = CreateUUID() />
<cfset CurrentOrder.Cart[myvar] = {type="foo"} />
Does anyone have any idea why using the CreateUUID() function directly in the assignment statement would cause a problem?
Mar 18 2009
After trying for a week or so to figure out some race conditions with Authorize.net's Automated Recurring Billing, I finally decided to email them and see if they could tell me what was going on. Well it turns out their system is busted, and they don't plan on fixing it. Read on for the details.
Read more...
Mar 6 2009
I've been having some serious memory issues with a ColdFusion application that I've narrowed down to CF's image processing functions. Processing no more than 14 megs of images causes a spike of nearly a full gig of RAM while the images are being processed. Here's an example of what's happening when I process images through CF's built in CFImage functionality.
Setup
I have 7 images, which average 2 megabytes a piece. I'm uploading them via a flash widget which processes each in turn in the background. As each image is uploaded, the following things take place:
- Image is uploaded to server
- The file is saved to a temporary location on disk
- Check to make sure it's a valid file with IsImageFile
- If it's not, readbinary and rewrite it
- Get the image info via cfimage
- If the image is wider than 400 pixels, size it down to 400 wide
- Insert a record in the database for this image
And that's it... nothing more. This is what the memory usage on my server looks like after uploading 7 images, and then shortly after uploading a single image using the same steps through a standard upload form (to get the flash processing out of the memory usage picture).

When I started the upload process of these 14 megs of images, the memory usage of the server (and I'm the only one using it) was idling at 80 megabytes. The plateaus on that spike (as one image finished processing, and the next started) are at:
- 253 mb
- 419 mb
- 586 mb
- 699 mb
- 817 mb
The smaller spike directly after was the single image I processed, which jumped from 260 mb to 304 mb.
Also, the server has never fully calmed down after processing the images. I'm really looking for some help to figure out what might be causing these issues. They're resulting in multiple JVM memory alerts daily, and other issues with the application such as dropped sessions and killed threads. If you've seen similar, or have a suggestion to alleviate the problem I'd love to hear it.
10-8-2009
10-8-2009
10-5-2009
9-29-2009
9-23-2009