Ok, I also have news...
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Geir Magnusson Jr.
>
> Paulo Gaspar wrote:
> >
> > Does someone have a clue on what the problem is?
>
> Actually, after a little investigation, I am starting to suspect exactly
> what the problem is...
>
> > Every time a use VMs, Velocity stops making sense.
> > Sorry, but I get so many weird things that I can
> > only describe it this way.
> >
> > Example:
> >
> > Having the macro:
> >
> > #macro (mymacro $cn $cv)
> > #if($cv)
> > <tr><td>$cn mm</td><td>$cv</td></tr>
> > #end
> > #end
> >
> > and
> >
> > #mymacro($somevar $emptyVar)
> >
> > something gets written all the time, even if the
> > $emptyVar is really "empty".
>
>
> I tried this. Here is my test template :
>
> #macro( foo $a $b )
> #if($b)
> yes:$a
> #else
> no
> #end
> #end
>
> #foo( "first" $lala )
>
> #set($lala = "foo")
> #foo( "second" $lala )
>
>
> and here is the output
>
> no
>
> yes:second
>
>
> Now, this contradicts your findings?
Sorry, but I was not clear enough yesterday (same excuse: did
not sleep and so).
The difference, as I mentioned 2 postings ago, is that I I use
a ResultSet wrapper that has that
public Object get(String i_varName)
and the problem is when the result is null.
I even tried passing the argument to a tool function to check
if it is null like in:
#macro( foo $a $b )
#if($tool.isNull($b))
yes:$a
#else
no
#end
#end
where tool would come from something like
class ToolClass
{ boolean isNull(Object i_obj)
{ return (null == i_obj);
}
}
But it does not work because of that wrapper object. I only went
as far as to find out that it was some private hard-to-identify
object - I could not see its members in the debugger- but I
still did not trace the problem to its foundation. That is what
I want to do now.
BTW, I tried to see the wrapper members because I was trying to
find how to get the wrapped object. Since the debugger could not
even get the class from the object, I kept not knowing where to
start. Is it some anonymous inner class or something like that?
Now, I think that
1. The #if() directive should resolve a reference that returns
null to as being false;
2. Macros should unwrap arguments before passing them to methods
called inside themselves.
While 2 looks clear to me, but maybe you think different about 1.
Anyway, I think 1 is the most intuitive way to go.
Thanks and have fun,
Paulo Gaspar