OK, I've been busy. With the holidays, projects at work, and studying for my CF 7 Certification Exam, I am a little behind on my postings. So, I thought to do a little cross work posting here. This is the full, un-edited article which I wrote for the December edition of 'Dealer Marketing Monthly', a publication targeted to the automotive dealership industry (for which my employer develops and hosts websites). Editors, lovely people that they are, cut the article content in half and changed the tone entirely, prior to publication, so I give it to you here in it's totally un-edited splendor. May you gain some small nut of insight/knowledge/humor from reading my ramblings.
There is more than one way to skin a cat. In our last tutorial I showed you an old, tried-but-true method for including page headers and footers. But, every ColdFusion developer knows that there are many different ways. In this tutorial we'll go over creating the same header and footer using custom tags.
Custom Tags provided a huge level of power to ColdFusion Markup Language, because it gave us the ability to write simple and elaborate code snippets that could be placed in a centralized repository for consistent reuse. One way to think of them is like an include, but with expanded functionality. Let's get started.
I want to welcome new readers from MXNA and Fullasagoog. I hope that there is a little something here for everyone. You can read my Welcome post for a little more about what you might find here at Cutter's Crossing, and you can check out Who I Am for a little more information about me and what I might bring to the blogosphere. Again, welcome one and all, happy reading, and let me know what you think.
So, now anyone following along has had plenty of time to come up with a few items they might include in a page template, variables that might change but layout consistent. Let's take a look at how we might apply the same layout from several different programming perspectives.
First I think we'll start off with basic includes. This is a technique used over and over again, and something that might apply in many different web development languages, but we'll just use trusty old ColdFusion. Let me point out something you don't want to do. Do not place your header and footer includes inside your Application.cfm (or cfc) or OnRequestEnd.cfm. Doing so would strip you of higher levels of control of your output and leave you in the wind if you require alternate displays on different pages, plus could cause you issues should you begin to use AJAX in your applications.
So tonight I did a presentation for the Nashville ColdFusion User Group on Object Oriented Development with Model Glue:Unity. This was a preso I was supposed to do last month, but some minor confusion with a new location (and the happy birth of a child a few days prior) had me standing in front of an audience of one. This actually worked out great, because it gave me an extra month to prepare, and allowed Aaron time to figure out the best way to record the presentation via Breeze (or 'Adobe Acrobat Connect Professional', as it is now called.)
This preso covered some "Why should I?" type questions, basic setup of the Unity frameworks and sample application template, as well as a hands on demo of using Reactor to do the grunt work. I need to give a big shout out to Aaron for picking up a really nice Logitech USB Headset w/ Mic the day before, as well as a thanks to all of those who attended either live or via the breeze session.
Once again, you can view the recording that Aaron put together during the presentation, or just go to the Nashville ColdFusion User Group's website. I'm including a FlashPaper copy of the slides with this post (the Download link below), but the hands on demo is in the presentation.
In every project there are gotchas, little unforseen issues that must be worked through as you migrate from development to production. In a previous post I brought up transitioning a Model-Glue: Unity application from a Windows development platform to a Linux platform while using two slightly different versions of MySQL. That would be one example.
Another recent project serves as a case in point as well, creating compliant header/nav/footer includes to be used site wide for a small site. Easy work, three or four files, including the stylesheets, with some example usage templates thrown in and a lot of comments for the developers who would use it. Oh yeah, did I mention it had to work on ColdFusion 5?
Wow, the things you forget over time. You start to work in a certain environment for so long that you take on bad habits by example of the work you are associated with. Trouble, with a capital 'T'.
Case in point. I was contracted out for a very small job, a friend of my company's Technology Director wanted to put a football pool on his website. Very straight forward, even for a guy like me who has little to no interest in sports. He sent in a hand drawn diagram of what he wanted each screen to look like, and exact instructions on the function of each page.
Easy. Simple. No brainer. So, I quoted him 4 hours of work. I wrote it in Model-Glue: Unity to play and learn, knocked it out over 2 days in about 8 hours (giving for learning curve), and had it fully functional on my server for testing. It worked great, and the client was getting a little more than he asked for in the process.
But then you have to deploy to production. Client's server environment. And this client was with a shared hosting facility. After three hours, and countless phone calls, they finally had all of the cf mappings set up correctly. This was necessary, since their site was not the webroot. I hit the page, and BAM!, error. My flawless little app was not functioning as intended, at all.
At first I thought it might have something to do with folder and file permissions. No dice. I was seeking advice left and right. Finally I asked Ray Camden for his thoughts, and he says "Look at case sensitivity."
Well, it was a Linux server. But, the majority of the pathing code was written by Model-Glue, so I was a little stumped.
With my version of MySQL, all table names are lower case, but queries can reference them without case sensitivity. In their version of MySQL, case sensitivity is queen (and a bitch at that), and can cause you great heartache.
You see, Model-Glue and Reactor autogenerate many files from your scaffolds and the Reactor.xml file, and use the same case sensitivity as that of your scaffolds and object setups. I had to recompile the site, page by page, with an adjusted config files, and then re-customize my display templates, plus rename a few thing within my Controller.cfc file.
So, in hind sight, I probably could have just changed the table names to the same case sensitivity as I had used in my files, but I just adjusted all of the files anyway. My overall point is this, always watch your case sensitivity. You may know, from the beginning, where and on what your application will be deployed, but what happens if your client decides to switch hosts the following year? Nightmare, with only yourself to blame. Be case sensitive to everything: paths, db tables and column names, CFC methods and arguments. Everything. You will save yourself a lot of trouble in the long run.
OK, it's been a little busy. BlogCFC has had a few updates (which still need to be applied here). One of the nicest updates I've seen is the liquid layouts. I replaced the Alagad image component with Efflare's imagecr3 tag. After extensive testing, I (and my colleagues) have found that the java imageio based tags were just not stable enough, nor was the conversion quality up to par. After looking through our (3,000+ templates) codebase, I wrote a new image.cfc wrapper for the imagecr3 tag, writing functions with names that matched those we were using within the Alagad component. Although the update to our three production servers definitely outlined our need for version control, overall the replacement of the image.cfc worked like a charm.
Stay tuned. I'm hoping, this week, to post another installment to my tutorial on "the View", where I'll begin to get in to making the templates dynamic. We might also talk about the use of <cfinclude> inside of CFCs and UDFs (some things to be aware of).
OK, what are Damon Cooper and the Adobe crew up to? There a post on Damon's Blog on What's Your Ultimate ColdFusion IDE? This has gotten some very interesting responses. Overwhelming support for CFEclipse, with suggestions on what to extend in it's feature set (everyone says 'Debugging').
And then Damon makes this cryptic remark:
Guys, thanks for the feedback this far. Much appreciated. We've heard you all loud and clear, and I, at least, realize now more than ever from this small sampling of feedback that our suspicions were correct.
I sincerely hope we can both pleasantly shock and awe you with what we have on store.
I will say this: the solution we come up with may not be what you're expecting, but it may be what just what you've wished for :)
Wow, do these people know how to tease us or what? I know that I saw at least two comments telling them to hire Mark Drew (and mine was one of 'em). I also saw quite a few things mentioned that I believe the CFEclipse crew is already working on (at least in R & D). Tell me, what do you think?
OK, been quite a few posts out there, within the CF community, about how you can download the ColdFusion RDS plugins for Eclipse (Well, CFEclipse). Now, if you have Flex Builder 2.0 then you already have it. At least I think you do, it might be an option during install, but either way it's available to you with Flex Builder 2.0. But, you can also go to that first link in this post to download it by itself. Install is pretty cut and dry, but you kind of have to search a little to find out what to do next.