ColdFusion 9.0.1 Release Date
by David J Henry on Jan.25, 2010, under ColdFusion
Mid April? I’m just guessing here.
AKC wants to avoid upgrading ColdFusion to a .0 release so I’m stuck in a holding pattern until 9.0.1 comes out. If anyone knows anything that they are allowed to share, please do!
Handling Null in ColdFusion
by David J Henry on Jan.19, 2010, under ColdFusion
CF uses duck typing to deal with variable types: if it quacks like an date, it must be an date. More on duck typing
When ColdFusion gets a null back from a Java function, it is much like a duck through a jet engine. It is going to happen eventually and the results range from gross to catastrophic.
The ColdFusion language doesn’t really consider null a possibility but CF is built on top of Java and null values can exist in Java. If you call a function from a Java object and assign the result to a variable, that variable can become null.
<cfset myJavaReturn = CreateObject("Java","com.coldfusionpowered.xmp.NullFactory").getNull()/>
ColdFusion doesn’t differentiate between a variable that has been set to a null value and a variable that was never set at all. In our example it will appear as if myJavaReturn never existed! As a CF developer you have several options to deal with this:
- Politely ask your Java developer not to return null
- Use a function like StructKeyExists() or IsDefined() to check for null after your call
- CFParam your variable after the assignment
- Wrap your function call in a UDF that ensures that a value is returned
- isNull() in CF9 (Thanks Henry!)
- Suggestions?
Many times, suggestion one is not possible. You maybe working with an established API or a middle tier that services more than just ColdFusion. You may just get laughed at and ridiculed by the Java devs for your arrays starting at index 1. Fortunately, checking the result isn’t hard in simple cases:
<!--- we can also create nulls in CF with a JavaCast --->
<cfset myJavaReturn = JavaCast( "null", "") />
<cfif not IsDefined("myJavaReturn")>
<cfset myJavaReturn = ""/>
</cfif>
If you have to do this a lot, you may want to wrap this up in a cffunction.
<cffunction name="AntiNull" hint="Assist with null values returned from Java, Returns an empty string if target is null.">
<cfargument name="target" default=""/>
<cfreturn arguments.target />
</cffunction>
<cfset myJavaReturn = antiNull(JavaCast("null",""))/>
I hope that helps you deal with nulls in CF. If you have another method for dealing with this, I’d love to hear it! Please comment.
Note: My blog frequently eats code in comments. I am working to correct this. I’ll try to fix your code examples if it doesn’t survive.
Shrink Your Virtualbox Dynamic Expanding Storage
by David J Henry on Jan.17, 2010, under Uncategorized
Thanks to Michael Cole’s Blog on Slimming down a Linux VirtualBox machine for this important nugget of knowledge.
I wrote a bunch of files to a dynamically expanding virtual disk in VirtualBox. After I deleted the files, the dynamic virtual drive on the host was still huge.
This is because the files on the virtual disk are not really gone, they are just unlinked from the file system, waiting to be overwritten with new data.
To get rid of this unwanted unlinked data (Linux), write over them with zeros like so:
sudo dd if=/dev/zero of=/zerofile; sudo rm /zerofile
sudo dd if=/dev/zero of=/zerofile; sudo rm /zerofile
Then shutdown your virtual OS and tell VirtualBox on the HOST machine (Windows in my example) to compress the virtual drive.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\djh>cd .VirtualBox
C:\Documents and Settings\djh\.VirtualBox>”C:\Program Files\Sun\VirtualBox\VBoxM
anage.exe” modifyvdi CentOS-cf7.vdi compact
VirtualBox Command Line Management Interface Version 3.1.0
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
0%…10%…20%…30%…40%…50%…60%…70%…80%…90%…100%
C:\Documents and Settings\djh\.VirtualBox
That freed up some space, nice!
CF Online Meetup - VirtualBox for the CF Developer: Results
by David J Henry on Jan.14, 2010, under ColdFusion, Dev Tools, Linux & Friends, Social
Questions about VMs, VirtualBox, Linux, ColdFusion or any combination are welcome at DavidHenry |at| coldfusionpowered.com
A link to the recording:
http://experts.na3.acrobat.com/p36124700/
Slides
http://blog.coldfusionpowered.com/wp-content/uploads/2010/01/vbox_for_cf_dev.pdf
Better Answers to Questions I Answered Poorly
Is Xen dead? No, Xen is alive and kickin’
Can you run a VM inside of another VM? To my surprise, yes. VirtualBox seems to allow this but it is extra slow.
What was the problem when you tried to use snapshots? The machine I was presenting from was using an old version of VirtualBox (3.0.12). The feature I was trying to show was introduced in VirtuaBox 3.1. Download directly from virtualbox.org to get the latest version for your operating system. Proper use of snapshots can be found at http://www.virtualbox.org/manual/UserManual.html#snapshots.
Magic commands to forward a port from host to guest “MyVM”
DOS/Terminal Commands
VBoxManage setextradata "MyVM" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol" TCP
VBoxManage setextradata "MyVM" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort" 80
VBoxManage setextradata "MyVM" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort" 8585
–== OR ==–
Edit {vboxhome}/Machines/MyVM/MyVM.xml
“pcnet” is the default network card, “0″ is the first network card
Add this to the <ExtraData></ExtraData> section:
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/GuestPort" value="80"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/HostPort" value="8585"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/Protocol" value="TCP"/>
Links
http://www.virtualbox.org/
http://download.virtualbox.org/virtualbox/3.0.12/UserManual.pdf
http://forthedeveloper.com/2009/coldfusion-virtualbox-and-ubuntu/
http://blog.zoobiesoft.com/index.cfm/2009/10/22/
http://httpd.apache.org/docs/2.0/mod/mod_alias.html#alias
Making the cfide directory map correctly in Apache2.
http://help.adobe.com/en_US/ColdFusionBuilder/Using/WS0ef8c004658c1089-38317734121cdfd5fd3-7fff.html#WS0ef8c004658c1089-38317734121cdfd5fd3-7ffe
ColdFusion Builder RDS setup instructions.
David Henry Presenting VirtualBox for Online ColdFusion Meetup
by David J Henry on Jan.11, 2010, under ColdFusion, Social

This Thursday night (1/14/2010) I am giving a presentation on the Online ColdFusion Meetup Group at 6pm. I am very excited about this! I’ll be presenting on Virtualbox for the CF Developer, showing how virtual computing can enhance your web development efforts.
I’ve been watching the CF Meetup since early 2007 when it was brought back by Charlie Arehart. Hundreds of speakers including most of my personal CF heros have given presontations on various CF-Related topics through the group. I am very proud to be joining this list of presenters.
Wish me luck! Hope I see you there.
RegEx GREP for UDFs that conflict with new CF9 functions
by David J Henry on Jan.07, 2010, under ColdFusion
You can also do this with the code analyzer in the CF administrator.
(?x)<cffunction[^>]+["'](?:
ApplicationStop|ArrayContains|ArrayDelete|
ArrayFind|ArrayFindNoCase|IsSpreadsheetFile|
IsSpreadsheetObject|FileSkipBytes|Location|
ObjectLoad|SpreadsheetFormatColumn|
SpreadsheetFormatColumns|SpreadsheetFormatRow|
SpreadsheetFormatRows|SpreadsheetGetCellComment|
CacheGetAllIds|CacheGetMetadata|CacheGetProperties|
CacheGet|CachePut|ObjectSave|ORMClearSession|
ORMCloseSession|ORMEvictQueries|ORMEvictCollection|
SpreadsheetGetCellFormula|SpreadsheetGetCellValue|
SpreadsheetInfo|SpreadsheetMergeCells|
SpreadsheetNew|CacheRemove|CacheSetProperties|
DirectoryCreate|DirectoryDelete|DirectoryExists|
ORMEvictEntity|ORMEvictQueries|ORMExecuteQuery|
ORMFlush|ORMGetSession|SpreadsheetRead|
SpreadsheetReadBinary|SpreadsheetSetActiveSheetNumber|
SpreadsheetSetCellComment|SpreadsheetSetCellFormula|D
irectoryList|DirectoryRename|EntityDelete|
EntityLoad|EntityLoadByExample|ORMGetSessionFactory|
ORMReload|ObjectEquals|SpreadsheetAddColumn|
SpreadsheetAddFreezePane|SpreadsheetSetCellValue|
SpreadsheetSetActiveSheet|SpreadsheetSetFooter|
SpreadsheetSetHeader|SpreadsheetSetColumnWidth|
EntityLoadByPK|EntityMerge|EntityNew|EntityReload|
EntitySave|SpreadsheetAddImage|SpreadsheetAddInfo|
SpreadsheetAddRow|SpreadsheetAddRows|
SpreadsheetAddSplitPane|SpreadsheetShiftColumns|
SpreadsheetShiftRows|SpreadsheetSetRowHeight|
SpreadsheetWrite|Trace|FileDelete|FileSeek|
FileWriteLine|GetFunctionCalledName|GetVFSMetaData|
IsIPv6|IsNull|SpreadsheetCreateSheet|
SpreadsheetDeleteColumn|SpreadsheetDeleteColumns|
SpreadsheetDeleteRow|SpreadsheetDeleteRows|
SpreadsheetFormatCell|TransactionCommit|
TransactionRollback|TransactionSetSavePoint|
ThreadTerminate|ThreadJoin|Throw|Writedump|Writelog
)["'][^>]*>
CF9: ColdFusion Administrator Code Analyzer
by David J Henry on Jan.07, 2010, under ColdFusion
I’m trying out the code analyzer in ColdFusion 9. It has a setting called “Code Version” that you can set to CF7 or CF8. Why no CF9 I wonder.
*nix and the /usr directory
by David J Henry on Jan.07, 2010, under Linux & Friends
/usr is short for “User”, right? How come it doesn’t have user related stuff in it?
I’ve wondered this for a long time. Today I discovered while searching for some unrelated information that it in fact stands for “Unix System Resources”.
Next they’ll tell me that /etc doesn’t stand for “Eggs Toast and Coffee”. Sheesh!
Unix/Linux Find Size of Files in a Directory
by David J Henry on Dec.10, 2009, under Bash, Linux & Friends
Wait… before I try to copy this directory recursively, how big is it?
du -sk /path/to/directory
-s : Display only a total for each argument
-k : Display size in KB
Oh dear. I’m going to need a bigger disk.
ColdFusion Force Header and Output Buffer Reset
by David J Henry on Oct.13, 2009, under ColdFusion
<cfscript>out = getPageContext().getOut();
method = out.getClass().getDeclaredMethod("initHeaderBuffer",arrayNew(1));
method.setAccessible(true); method.invoke(out,arrayNew(1));</cfscript>
This will remove all html/text output in your page execution prior to running it. Handy if you need to get rid of some white space or, in my case today, output from code that is outside your control.
Note: This will not work if a <cfflush> has been executed.