Handy JavaScripts

Over time I have found a handful of nifty little JavaScript utilities. I was about to compile a handy reference of them for myself when I realized that others might be interested in them as well.

These are scripts that I have used and liked as well as some scripts that I haven't used book look nifty.

Here they are in no order:

General

Menus
WYSIWYG Editors
Let me know of any other scripts that I should add to the list.

CFML on J2EE or .NET

With the release of BlueDragon 6.2, CFML (ColdFusion Markup Language) becomes the first language (of which I am aware) that runs natively on both J2EE and .NET.

Both ColdFusion and BlueDragon both have J2EE versions that run natively on top of J2EE. BlueDragon also has a .NET version that runs natively on .NET. If you don't know if your organization will standardize on J2EE or .NET, CFML is a great option. Even if you don't use BlueDragon, the ability to easily switch to .NET is a powerful option for CFML developers.

I am really excited about the recent releases of BlueDragon 6.2 and ColdFusion MX 7. I think they both bring a lot to the table for ColdFusion developers. Many of these advantages really put ColdFusion (or CFML) developers ahead of the pack.

Related Links:
New Atlanta announces BlueDragon 6.2
Charlie Arehart on BlueDragon 6.2
More on BlueDragon 6.2 features

Product Links:
New Atlanta BlueDragon 6.2
Macromedia ColdFusion MX 7

New Security Update for Firefox

Today Mozilla released Firefox 1.0.2 to fix a security problem in its processing of gif images.

Download Firefox 1.0.2 from Mozilla today.

Hide Your Errors (Application Events: onError)

I have noticed that a great many ColdFusion sites show the default ColdFusion error when something goes wrong. This is a bad idea for many reasons.

In the "Research-Based Web Design & Usability Guidelines" (pdf) put out by Usability.gov, "Detect Error Automatically" was given an importance of 5 out of 5. In his popular "Top 10 Web Security Tips" article, Michael Smith listed "Have an error-handler" as his number-one security tip.

In his article "Toward Better Error Handling" (part 1, part 2, part 3), Charlie Arehart covers some techniques for error-handling in ColdFusion. As of the release of ColdFusion MX 7, a new method exists for handling errors in ColdFusion; the onError event of Application.cfc.

[More]

A Concise Guide to Major Internet Bodies

No, this doesn't have to do with your favorite celebrity. I'm not talking about that kind of body.

The Association for Computing Machinery has put together a guide to the major ruling bodies of the internet. If you want to know who is in charge of what, this guide is the best place to start looking.

A Concise Guide to the Major Internet Bodies

Offer Eyetracking to your clients

Eyetools Research will let you resell their services and offer eyetracking studies to your clients.

For the uninformed, eyetracking studies measure where users actually look on your web site. This will include the order in which people look at things on a web page as well as where most people look (using a Heat Map). This information can be invaluable in determining how usable your web page is.

Although I don't pretend to know anything about the industry, their pricing seems reasonable and they offer discounts to resellers.

I find this really exciting and I plan to mention this to my clients (by way of this blog entry). It would be really nice if Eyetools made some materials available for use on reseller web sites and promotional materials. I would love to start offering this service in the future and have information that I could easily put on my web site to accurately and effectively describe the service.

Find out more about offering eyetracking to your clients. I will definitely continue to keep an eye on Eyetools (especially their eyetracking tests of CSS Zen Garden).

Ditch ColdFusion Evaluate()

The topic of evaluate() recently came up on the CFCDev list. Sean Corfield asserts that evaluate() is only needed for backward compatibility since all variables scopes can be treated as structures as of ColdFusion MX. He argues against its use in any new code siting performance reasons.

Here are some situations in which you might be using evaluate(), but don't need to do so.

1) Getting the value of a Form variable where the field name is (or contains) a variable.

Using evaluate:
<cfset foo = evaluate("Form.bar#i#")>

Without evaluate:
<cfset foo = Form["bar#i#"]>

Since Form is now a structure, you can use structure syntax to get the variable. This will work in other scopes as well (request or URL, for example).

2) Get the value of a column in a query where the column name is (or contains) a variable.

Using evaluate:
<cfset foo = evaluate("qBar.text#lang#")>

Without evaluate:
<cfset foo = qBar["text#lang#"][CurrentRow]>

The important thing to keep in mind with queries, is that while you can use structure syntax, you must indicate the row. The "CurrentRow" variable is handy if you are within a query loop (using the query attribute for the given query in either <cfloop> or <cfoutput>). Otherwise, you will have to pass in the number another way. If you know you want the first row, for example, you could simply pass in 1.

3) Checking the existence of a variable.

This isn't actually an evaluate() issue, but I know that Mr. Corfield also recommends avoiding isDefined() in favor of StructKeyExists(), so I thought I may as well cover that here as well.

Using isDefined()
<cfif isDefined("Form.bar#i#")>

Using StructKeyExists()
<cfif StructKeyExists(Form,"bar#i#")>

The same principle applies here as from the first example. Since "Form" is a structure, it can be treated as such (as can other variable scopes).

If you have any other situations in which you currently use evaluate(), let me know.

Good luck!

UPDATE

Scott Stroz noted that you can use the same approach with queries as well. Since the format doesn't show up correctly from comments, here it is:

The format for that would actually be:

<cfset foo = qBar["column name"][CurrentRow]>

or, with a variable,

<cfset foo = qBar[colvar][CurrentRow]>

Scott's example for queries and columns:

<cfset foo = qBar["A column with spaces"][currentRow] />

<cfset foo["a structKey with spaces"] = 'bar' />


Thanks Scott!

Prevent duplicate Inserts

I frequently need to insert a record that relates to tables to each other (or relates one table to external data) and I cannot have a duplicate record. Here is my method for doing this in case it helps anyone and as a convenient reference for myself.

Let's suppose that you have three tables: Users, Classes and Students. Classes has a primary key of ClassID (int). Users has a primary key of UserID (int). Students has a two-column primary key of ClassID and UserID which relate to the corresponding columns in Classes and Users respectively.

[More]

Web Services Guru Needed

I am working on two projects that need to share data and it looks like web services will be the best option. These projects may influence the standards of other similar projects.

I want to make sure that the web services are written in a manner that will be viable for future use across any projects of this type (which will likely be written in differing programming languages). Since I don't yet have any production experience with web services, I would certainly like to have someone available for (paid) consulting.

If anyone has a solid foundation in web services and might be available for some consulting work, please let me know. You can contact me using my contact form, or you can send me an email (my first name at my domain name).

Outer Join on Multiple Fields

I ran into a situation where I needed to do an outer join on more than one field (if only SQL supported such a thing). After banging my head against a wall for a bit, I asked the CF-Talk list.

Lo and behold! SQL does support exactly what I want. I was just to dim to try it myself. Mark Gaulin provided the answer:

[More]

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.