fusiongrokker

Entries for month: December 2007

For everyone who *wishes* they could go to CFUnited

Here's something to stick in your sidebar. I added it to mine yesterday.

I wish I was attending CFUnited

Posted in CFUnited | ColdFusion December 19 2007

Tag wrapping made easy!

The other day I was in a state of head banging frustration while debugging an issue with a component invoked via a CF Gateway that was peppered with calls to the ImageCR CFX, and seemed to be failing at random points for random reasons (though through no fault of ImageCR, it should be noted). My examples will use ImageCR for reference, but this should be a method you can apply to any ColdFusion Tag, Custom Tag, or CFX.

I spent a good hour racking my brain, trying to write a custom tag that would allow me to wrap any code in a try/catch block that would email me a CFDump of the CFCatch struct, like so:

[viewcode] src="cfx_imagecr3_support1.cfm.txt" showsyntax=no geshi=cfm[/viewcode]

This would have made it very easy to wrap any block of code in a try/catch that will email me on error. As it turns out, this isn't possible without some clever use of CFFile and Regex to read the contents of the calling template and locate the block of code between the start and end tag of the custom tag. But I'm sure you're already thinking about how inefficient that would be, especially in my case where there are 20, 30, maybe more instances. And I agree with you.

Then, it hit me like a ton of bricks: Take one step back — just the one tag causing my grief, not a general code block — and write a wrapper for that one tag. And to make things even simpler: Use AttributeCollection! I can pass easily everything sent to my wrapper on to the CFX as an AttributeCollection, without knowing what it is.

So I slammed together a quick wrapper custom tag (File name: "/customtags/wrappers/cfx_imagecr3.cfm") as this:

[viewcode] src="cfx_imagecr3.cfm.txt" showsyntax=no geshi=cfm[/viewcode]

Notice that after I save the contents of my special attributes (trymailto and trysubject), I delete them from the attributes struct. Different tags and CFXes will react differently to unexpected attributes, so it's best not to include them.

After simply importing my new tag wrapper:

[viewcode] src="cfx_imagecr3_support.cfm.txt" showsyntax=no lines=1 geshi=cfm[/viewcode]

This tag:

[viewcode] src="cfx_imagecr3_support.cfm.txt" showsyntax=no lines=2 geshi=cfm[/viewcode]

Becomes this tag:

[viewcode] src="cfx_imagecr3_support.cfm.txt" showsyntax=no lines=3 geshi=cfm[/viewcode]

I can customize the to address and subject of the email per-usage, if I like, and I get an email any time one of them fails.

Posted in ColdFusion December 18 2007

ModelGlueCookbook Launches!

Todd announced on his blog on December 10th that he was putting together a site called Model-Glue Cookbook, based on the same idea as Ray's ColdFusion Cookbook (and apparently the same codebase), though at the time the domain was parked and there was no content. I've been checking in on the domain a few times a day and this morning there's finally something there to be had! Go check it out!

Posted in ColdFusion | Frameworks December 17 2007

ColdFusion Guitar Hero (Wii) Players Unite!

Over on ColdFusionCommunity.org, there's a group for Wii owners, and in that group, a thread for folks to share their friend codes. Considering the number of CFers that have been gravitating to the Wii lately, and the fact that almost everyone likes to play Guitar Hero, there ought to be at least a few people out there who would appreciate playing with some familiar names now and then.

So if you play Guitar Hero 3 on your Wii, come on over and get some friend codes for other CF developers. Remember to post yours in the thread, because you can't see your friends online until you've both added each other's codes.

Posted in Community | Games December 06 2007