velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shinobu Kawai <>
Subject Re: Problem handling null values
Date Thu, 04 Nov 2004 21:30:06 GMT
Hi Steve,

> I've got a table that outputs values from a 2 dimensional array of Strings;
> <table>
>    #foreach ($Item in $Results)
>    <tr>
>        #foreach ($Field in $Item)
>            <td>$Field</td>
>        #end
>    </tr>
>    #end
> </table>
> This works fine except when it comes across a null string in $Field.
> What it actually does is output the previous non-null value for $Field.
> I assume this is a bug?
It's the way Velocity handles null:  Shun the whole process.  :(
So if you want to handle nulls in the array as null, you need to
null-ify the element at the end of the loop.

Using NullTool (
  #foreach ($Field in $Item)
    $null.setNull($ctx, "Field")

Or ViewNullTool (
  #foreach ($Field in $Item)

Best regards,
-- Shinobu Kawai

Shinobu Kawai <>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message