What's the best way to test for a Java NULL in CF?
For instance, the following code:
cfset my_url =
createobject(java,java.net.URL).init(http://www.yahoo.comy;)
cfdump var=#my_url#br /
getpathcfdump var=#my_url.getpath()#br /
getauthoritycfdump var=#my_url.getauthority()#br /
getfilecfdump var
Yeah, using structKeyExists or isDefined is what you have to do. Kind
of annoying, but such is life.
cheers,
barneyb
On Tue, Jun 24, 2008 at 9:26 AM, Brad Wood [EMAIL PROTECTED] wrote:
What's the best way to test for a Java NULL in CF?
For instance, the following code:
cfset my_url
Brad Wood wrote:
What's the best way to test for a Java NULL in CF?
Should I just set the output of each of those methods into a variable,
and then check for the variables existence?
That'll work.
cfset path=my_url.getpath()/
cfif isdefined('path') !--- ... --- /cfif
We use a little Java
Thanks Barney.
I did dig up a little snippet of help while Googling.
The trim() and len() functions will accept a null and return an empty
string and 0 respectively.
#trim(Obj.i_return_null())# returns empty string
#len(Obj.i_return_null())# returns 0
Thanks.
~Brad
-Original
Ach! It stripped it. Here's the class:
package horus.coldfusion;
// Java-end NULL-surrogate bits for ColdFusion
// Copyright © 2007-2008, Horus Web Engineering Ltd. All rights reserved.
public class undefined {
private Class test=null;
public undefined () {
this.test=this.getClass();
]
Sent: Tuesday, June 24, 2008 12:35 PM
To: CF-Talk
Subject: Re: Java NULL in CF
Brad Wood wrote:
What's the best way to test for a Java NULL in CF?
Should I just set the output of each of those methods into a variable,
and then check for the variables existence?
That'll work.
cfset path
12:35 PM
To: CF-Talk
Subject: Re: Java NULL in CF
Brad Wood wrote:
What's the best way to test for a Java NULL in CF?
Should I just set the output of each of those methods into a variable,
and then check for the variables existence?
That'll work.
cfset path=my_url.getpath()/
cfif
7 matches
Mail list logo