« April 2007 | October 2007 »

August 27, 2007

ColdFusion is the next FrontPage

Web professionals around the world rejoiced when Microsoft recently announced that they were discontinuing their infamous FrontPage WYSIWYG web authoring program. FrontPage, which was designed to make web site creation as easy as word processing, was scorned by web professionals due to the non-standard, proprietary Microsoft spaghetti HTML code that it generated. Many people could identify a web site created with FrontPage at first glance and the program and the sites that it created quickly became synonymous with amateur, wannabe web designers.

Unfortunately, the old FrontPage is now being replaced with a new “FrontPage.” Only this time it’s called Adobe ColdFusion 8. With the recent release of version 8, ColdFusion is being trumpeted as the quickest and easiest way to web applications. Sound familiar? Just replace “web application” with “web site” and you’ve got almost identical product slogans. What FrontPage attempted to do for static web sites, ColdFusion is trying to do for dynamic web applications. But this slogan doesn’t necessarily make ColdFusion a bad thing. Let me explain a little bit…

I use ColdFusion every day at work as a web application developer for the City of Portland. And I love ColdFusion because I honestly do believe that it is the quickest and easiest way to build powerful web applications. So when version 8 was recently released I was thrilled to learn about the new Ajax features designed to make building Ajax enabled applications easier than ever before. Having already built a couple of Ajax enabled web apps “the hard way” I was curious to see how well ColdFusion was able to simplify the process.

So after downloading and installing the developer edition on my computer, the first thing I did was experiment with some of the new Ajax features. I was pleasantly surprised to discover that Adobe had fulfilled their promises and kept to the ColdFusion tradition of abstracting typically difficult tasks into dead-simple and easy to use tags. In just a few lines of CFML code I was able to add an Ajax auto suggest text box. With a few more lines of CFML and little ColdFusion component, I was able to create a “live HTML data grid” complete with automatic paging, dynamic on request record loading, and edit-in-place functionality. Not once did I even have to know a thing about JavaScript or how Ajax functionality works—ColdFusion magically took care of all those details behind the scenes for me.

“Wow!” I said to myself as I hit the view source button in my browser, “Let’s see how they did it…”

It was at this point that the music suddenly stopped, the lights began to dim, and the smile quickly faded from my face. I’m a big advocate of standards-based web development and I usually try to create pages that conform to the XHTML Strict doctype. The first thing that I noticed was that while the HTML code that I’d used was valid, there were several validation errors in the ColdFusion generated code.

What’s worse is that they were all simple, easy to fix errors that could have been avoided had the ColdFusion engineers taken a little more pride in their work and taken the time to verify that they were generating valid code. Maybe you don’t think it’s a big deal if there are minor validation errors “so long as the page looks okay and functions correctly.” Here are two reasons why I feel that it is a big deal. First, if you want to serve your XHTML pages as XML documents (as they are supposed to be served) instead of as “text/html”, the page must be valid. Otherwise the browser will just show the user an ugly XML parse error. Second, due to its ease of use, ColdFusion is used by a lot of novice developers. For these users ColdFusion is often their introduction to HTML, CSS, JavaScript, server-side programming, and all of various technologies that go into creating a web application. Do we really want them using the ColdFusion generated code as a learning tool? Adobe should strive to set a good example by following the industry standards and best practices in their code so that developers using it as a learning tool will learn good habits and learn to do things “the right way.”

The next thing I noticed when looking over my page’s source code was that ColdFusion automatically included a bunch of Yahoo YUI and Ext JS JavaScript files based on the specific requirements of the particular CFML tags used on the page. I think it’s great that the ColdFusion engineers chose to take advantage of some of the great open source JavaScript libraries out there. But this brought up an interesting question to my mind. What if a ColdFusion developer wanted to use those same libraries to develop custom JavaScript functionality in their web application? And let’s say for the sake of this example, that not every page on the web site uses one of the CFML tags that automatically includes the JavaScript libraries. The developer would need to ensure that the libraries are included anyway on those pages to support their own custom JavaScript functionality.

So the developer manually hard codes in links to the JavaScript libraries in an application wide template so that they will be included on every page regardless of the CFML tags used on the page. But what happens on the pages that do use the CFML tags that automatically include the JavaScript libraries? Well, it turns out that the libraries get included twice—once by the developer’s template and again by the ColdFusion tags! This is not good! At the very least the browser will make two HTTP requests for each script file, possibly resulting in many redundant requests. (At least the second time the script should get loaded from the browser’s cache). In the worst case scenario, it could potentially cause the scripts not to function property because each one will get run/initialized twice by the browser. Now, how hard could it be for ColdFusion to verify that the JavaScript libraries are not already being included on the page before automatically including them again?

It seems that when it comes to creating a web site, whether it’s a static web site or a dynamic web application, if you want it done right you’ve got to do it yourself. This includes hand coding your HTML and handling the nitty-gritty details of Ajax enhanced web sites. This brought me to the conclusion that ColdFusion is just the next FrontPage. No doubt the new Ajax features will get used and abused by the less knowledgeable developers looking for the quick and easy solution. But smart developers who care about web standards and take pride in creating clean, semantic, valid HTML will do things the way they’ve always done them in the past—by hand. So the next time your tempted to use on of the new ColdFusion features that magically does everything for you, take a look behind the scenes at what’s really going on and evaluate if it’s really the best way to accomplish your task. You may find yourself joining me and doing it the hard way. But at least it will get done the right way!

P.S. Adobe, if you’re listening, it’s not too late! I’d love to be surprised by the next ColdFusion update to discover that you’ve fixed these issues that you’re putting forth an effort set a good example and do things the right way. If so, I promise I’ll never mention ColdFusion and FrontPage in the same sentence again!

Posted at 8:12 PM in ColdFusion | Comments (10)

August 20, 2007

Firefox tweak: Spell check any text field

Here’s an easy Firefox tweak to enable spell checking of single-line text fields. (By default, only multi-line text boxes are spell checked.)

  1. Type about:config in the address bar and press enter
  2. In the filter field type layout.spellcheckDefault
  3. Double-click on the entry and in the pop-box enter 2
  4. Click OK
  5. Restart Firefox

Source: Firefox 2.0: Spell Check Tweak - Firefox Extension Guru’s Blog

Posted at 9:43 AM in Internet

August 15, 2007

Automatically stretch Webshots backgrounds

I recently upgraded from an old 19" CRT monitor to a 19" widescreen LCD monitor. While the widescreen is great for watching movies, my Webshots desktop backgrounds don't fit the new aspect ratio very well.

By changing the background properties from center to stretch I could force Windows to resize the background to fix the screen. Although this slightly distorts the picture, I found that I preferred it to the black bars normally on the left and right sides of the picture. The only problem is that every time Webshots changed the background picture, it would change the background setting back from stretch to center.

I finally found a way to automatically "stretch" the background pictures after Webshots changed them. I found a very useful program called AutoIt. According to their web site, "AutoIt is a freeware Windows automation language. It can be used to script most simple Windows-based tasks."

I wrote a little script that changes the wallpaper mode to stretch. Then I used the compiler that comes with AutoIt to compile the script into an executable .exe file. Then I created a scheduled task that runs the executable every minute.

So now when Webshots changes the background, it will automatically get stretched within a minute when the scheduled script runs.


;
; AutoIt Version: 3.0
; Language: English
; Platform: Win9x/NT
; Author: Richard Davies
;
; Script Function:
; Changes wallpaper mode to 'stretch'.
;

Dim $pos
$pos = RegRead("HKU\S-1-5-21-1645522239-2139871995-725345543-1003\Control Panel\Desktop", "WallpaperStyle")

If $pos <> 2 Then
; Load display properties
Run("control desk.cpl display,,2")

; Wait for it to load and make it transparent
WinWaitActive("Display Properties")
WinSetTrans("Display Properties", "", 0)

; Set wallpaper mode to stretch
Send("!p")
Send("s")

; Close window
Send("{enter}")
EndIf

The registry string in the second line is your SID. You can use the PsGetSid utility to find your SID.

Update: See Automatically stretch Webshots backgrounds redux for an improved (and Vista compatible) method of accomplishing this task.

Posted at 7:18 PM in Computers