Friday, October 04, 2002

Get CFMX Version of the CFML Reference to Studio and HomeSite+ Help Tab

If you're running CF4.5 or 5 of Studio, you may be interested in having the CFMX version of the CFML Reference available in the Help Reference Tab in Studio (Help>Help References Window). Also, folks running HomeSite+ may have noticed that there, too, the help reference doesn't include any CF manuals at all. Grr.

(I'm not referring here to the help shown when you press F1 on a tag or function, but instead the actual help tab listing several available books.)

Macromedia has solved the problem, at least a little. You can go to and download a zip file. Follow the instructions in the CFMLRef_install.txt file on where to install it and optionally how to improve its appearance inside the help tab once installed (by editing the booktree.xml file it talks about). This will cause you to have the CFMX version of the CFML Reference manual available in the help, but not the other CFMX manuals.

While the instructions apply to HomeSite+, they're equally applicable to previous releases of HomeSite and Studio. Try it!

BTW, if you're still using Studio 4.5 or 5 and want to update those, such as to add patches that came out after the product's release or to get tag help, insight and completion for CF 5 in Studio 4.5, those are all separate updates. See my blog entry of August 1 for more details.

How CFMX creates the filename for the compiled version of your CF code

In previous bog entries I've talked about compilation and precompilation of CFMX code into Java. One thing that's been a mystery to many is how CF decides to name the files it creates. Since all CF templates (from all directories) get compiled into the same [cfusionmx]\wwwroot\WEB-INF\cfclasses directory, without any rendering within subdirectories there, there needs to be a way for CFMX (and us) to associate a given file with its source directory.

A CF template named Setsession.cfm might lead to a class file named cfsetsession2ecfm1011928409.class. The numbers that follow the 2ecfm are a hashing of the directory name. Here are the details from Mike Nimer at Macromedia:

How CFMX creates the .class name, or how you can find the name of the .class file you want to delete

The formula is: "cf" + filename + hashCode

The fully canonicalized filename is used, with "/" as the directory separator. The following substitutions are made in the filename:
1.) / becomes __
2.) any other character which would be illegal in a Java identifier is represented as 2 hex digits

hashCode is the hashCode() of the File object which represents this file as documented at

If the hashCode() is negative, it is exclusive-OR'd with 0xFFFFFFFF to get the value used by ColdFusion.

Note that even two files in the same directory could end up with hashcode values that are different. You can prove this by creating two templates in the same folder, with distinctive names that you can readily identify, and then save and execute those pages, and view the latest class files created in the cfclasses folder. Do both those distinctively named files in the same folder show having the same or different codes? If anyone may be able to help understand how that can happen, I'd love to hear.

Thursday, October 03, 2002

Pausing your CFMX code

Folks have often wanted to pause their CFcode, particularly when wanting to simulate some sort of long-running task. Usually they use a CFLOOP, but now that CMX is built upon Java, there is a better and less resource intensive way. Java has a "sleep" method in the java.lang.Thread object. You can get a wait by doing the equivalent:

<cfobject type="JAVA" name="obj" class="java.lang.Thread" action="CREATE">

<cfset obj.sleep(10000)>

This will pause 10 seconds.


To make it even easier, I've created a custom tag to handle this, called cf_sleep. It's available both at the DevExchange and via my site. You would use it in the form:

<cf_sleep seconds="nn">


It's also available as a UDF, in which you might use it in the form:

<cfinclude template="sleep_udf.cfm">
<cfset tmp=sleep(2)>

Believe it or not, this approach works in CF5 (and 4.5) as well as MX, since the ability to call Java objects was introduced back then.