Wednesday, September 22, 2010

magicExcel Makes Excel Spreadsheet Generation Simple

Have you ever had trouble wading through the ColdFusion 9 documentation pertaining to the new CFSpreadsheet Functions? Have you ever gotten frustrated with generating Excel documents with ColdFusion? Are you tired of boring spreadsheets? Don't you wish there was an easier way to do it all?

You're in luck! A new RIAForge project called "magicExcel" makes all this super simple. Using a custom tag, all you have to do is write HTML.

Wait! What?

Yes, that's right! All you need to create sleek spreadsheets is knowledge of HTML tables.

Don't believe me, check it out for yourself at

Monday, September 13, 2010

Creating Custom Tags with Flexible Closings

While I was cleaning up some code in a portal of ours, I realized that I could condense some of the code by combining a variable assignment with a custom tag attribute assignment.

To make things simple, the tag I am trying to optimize creates a database record with a note assigned to it.

  <cfset notes="A ton of html code here.">
  <cf_my_tag notes="#notes#">

The issue is that this code wouldn't necessarily add a note in the same manner, every time. There might be times where I have to build the notes in a loop before I run the tag. Then there are times where I want to run the tag and NOT add a note. Also, I might want to define the note directly in the tag contents.

So here are the requirements for my new custom tag:

  1. The tag must be willing to accept an attribute named "notes"
  2. The tag must be willing to run without defining "notes"
  3. The tag must be willing to transform its contents into "notes", if it is not empty.

With the above constraints in mind, here's what I came up with.

This setup fulfills all three requirements:

  1. I can refer to the ATTRIBUTES.notes variable to insert my note.
  2. I don't need to define ATTRIBUTES.notes as it is param'ed at the top of the tag.
  3. If I have a closing tag with a non-empty string for its GeneratedContent, the ATTRIBUTES.notes variable will be overwritten with the GeneratedContent. This works for self-closing tags as well.
  4. It also allows me to place my logic into a single function rather than splitting it up in an if..else block.

So there you have it. A simple solution to create a custom tag with flexible closing tags. If you have any questions/comments/concerns, please let me know. I'd love to hear your feedback.

Sunday, August 29, 2010

cfsavecontent cannot be defined and used in the same cfoutput block

I was playing around with cfsavecontent to generate dynamic HTML variable values for use as an argument to a function when I came across an interesting behavior regarding the tag. The issue I ran was that Coldfusion was giving me an error that the variable saved by cfsavecontent was not defined when I was trying to output the value. Take a look at the code below:

As soon as I figure out how and where, I will be submitting a bug report on this issue. You shouldn't have to use separate cfoutput blocks to create and then display content from a cfsavecontent.

CFUnited Day 3

Yeah, it's a bit late to post this, but I figured what the heck.

Day 3 of CFUnited presented some interesting talks. The highlight of my day was the talk on FW/1 by Sean Corfield.

FW/1 seems to be a very solid MVC framework in ONE file (that's actually how it got it's name) and works on certain conventions. This is great for development at my job because it allows us to move toward conventions with a lightweight footprint as well. I have a feeling you'll see more posts about my experiences with FW/1

That's all for now.

Thursday, July 29, 2010

CFUnited - Day 2

Day 1 of CFUnited was (honestly) a little overwhelming, but there were a few very good talks that should help out at work. As our shop does not use any ColdFusion MVC frameworks, the conference is focusing on a lot of framework stuff. As such, the topics today should hopefully fill in some of the blanks. Today is pretty much filled with talks about the CF on Wheels framework. I'm extremely excited to learn about it. Otherwise, I'm having a blast at CFUnited.

Feed Share