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!
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!
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:
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.
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!
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
)["'][^>]*>
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.
/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!