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.
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.
Registration opens today! Get registered now for this FREE conference! http://cfinnc.com/

Guess what! The model-glue framework just released a beta of version 3!
As I mentioned in an earlier post, I’ve been having fund helping the team to organize and publish documentation for the new features in version 3. I am really impressed with how fast I’ve been able to get up to speed with this framework with only a few spare minutes per night and a little reading.
This framework lets parts of your application quite literally write themselves. Customize the results and only write from scratch only when necessary. Less busy work, more results, oh yeah!
New features include:
A summary list of these features can be found at http://docs.model-glue.com/wiki/NewFeaturesInMG3