You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Eric Wiseblatt <er...@yodaya.com> on 2001/12/06 16:46:57 UTC
passing null fields to macros
I hope this is an appropriate forum. It's the best link I could find on
from the Velocity site.
I'm trying to pass a null field to a macro, but it seems that velocity
is converting the null to an empty string when going to a macro.
For example, I claim the following template would output
NO NULL
NO Value is '' | java.lang.String
#macro (broken $value)
#if ($value)
Value '$value' | $value.getClass()
#else
NULL
#end
#end
#if ($!bogus)
YES
#else
NO
#end
#broken($!bogus)
#if ($!bogus.field)
YES
#else
NO
#end
#broken($!bogus.field)
Is there some setting that controls this? Is it a bug (I hope)?
If it is a bug, how would I go about fixing it (or having it fixed)?
Please CC me on any mailing list replies as I dont subscribe.
Thanks.
- eric
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: passing null fields to macros
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/6/01 10:46 AM, "Eric Wiseblatt" <er...@yodaya.com> wrote:
> I hope this is an appropriate forum. It's the best link I could find on
> from the Velocity site.
This would be the place!
>
>
> I'm trying to pass a null field to a macro, but it seems that velocity
> is converting the null to an empty string when going to a macro.
>
> For example, I claim the following template would output
> NO NULL
> NO Value is '' | java.lang.String
Do you mean 'does output' or 'should output'?
Using what version? I get :
NO
NULL
NO
NULL
Which I think is the right behavior
using whatever is sitting in my dev tree (1.3-geir :)
I did a fix to this 'recently'. Try the 1.2-rc3 and see if that helps.
>
> #macro (broken $value)
> #if ($value)
> Value '$value' | $value.getClass()
> #else
> NULL
> #end
> #end
>
> #if ($!bogus)
> YES
> #else
> NO
> #end
> #broken($!bogus)
>
> #if ($!bogus.field)
> YES
> #else
> NO
> #end
> #broken($!bogus.field)
>
>
>
> Is there some setting that controls this? Is it a bug (I hope)?
> If it is a bug, how would I go about fixing it (or having it fixed)?
> Please CC me on any mailing list replies as I dont subscribe.
Please subscribe. I will not CC from this list, but will do a courtesy
forward once :)
Geir
> Thanks.
>
> - eric
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Be a giant. Take giant steps. Do giant things...
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>