You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Dennis Doubleday <dd...@mail.yourfit.com> on 2001/04/25 19:14:02 UTC

Null String arguments to methods

I want to call a method on an object I have placed in my context. The 
method has 8 string arguments, and it has that ignores null arguments. 
However, I can't see that it is possible to pass a null String from VTL--I 
can only pass the empty string. So, in order to use this existing class 
from VTL, I have to rewrite all bits of code in the method from

if (arg != null) {
     do something;
}

to

if (arg != null && arg.length() != 0) {
     do something;
}

which is unfortunate, not to mention that if I do that, I have no way to 
know if the VTL writer actually DID want an empty string rather than a null.

Maybe I missed something in the spec--is it possible to pass a null value 
in the arg list?

-------------------------------------------------------------
Dennis Doubleday          email: dday@yourfit.com
yourfit.com, Inc.           web: http://www.yourfit.com/