All,
Many thanks. Changing $item.Folder_code from a byte to an int wasn't a good
option, as it is part of a core data class. The easiest fix (once I
realized the cause of the problem) was to make the following changes:
-in the Java module, add this line: context.put("byte", new
Byte((byte)0));
-in the template, change previous line to this:
#if($byte.toString($item.Folder_code) == "0")
BTW, I'm *very* impressed with Velocity. I'm converting an entire
Enhydra-based application to it as we speak (well over 100 'pages'). Since
I'm still in a 'beginner's mind" mode (read, Velocity newbie), here are a
couple of observations so far in terms of formal user/developer
documentation suggestions:
1. make it more clear that string varbs are concatenated without '+' between
terms and *must* be enclosed in quotes.
2. explain how $formatter works
3. explain how to make comparisons with non-integer values
I'm learning that Velocity is *incredibly* powerful and flexible, but I also
find I have to dig around a lot to find how to use some of these
capabilities. I'd be glad to help someone insert these suggested wording
additions (and others I find) into the docs if desired.
Best regards,
Terry
----- Original Message -----
From: "Geir Magnusson Jr." <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 11, 2001 11:53 PM
Subject: Re: VTL Logic Problem
> On 10/11/01 11:38 PM, "Terry Steichen" <[EMAIL PROTECTED]> wrote:
>
> > All,
> >
> > I'm having trouble making some simple-looking VTL branching logic work.
It
> > looks like this:
> >
> > 1 #foreach($item in $items)
> > 2 #set ($test = $item.Folder_code)
> > 3 <td>$test</td>
> > 4 #if($test == 0)
> > 5 <td>file</td>
> > 6 #else
> > 7 <td>folder</td>
> > 8 #end
> > 9 #end
> >
> > The value of $test that is printed is just fine (line 3 above) - but the
> > branching logic
> > (lines 4 through 8) doesn't work at all.
> >
> > Now if I change the #set line to directly assign any number to $test
(line 2)
> > equent branching logic works just fine. The problem seems to be in
> > assigning $test the value of $item.Folder_code (line 2), which happens
to be a
> > byte.
>
> A byte? No, that won't work. Integer comparisons only.
>
> >
> > I went through the docs and the archives trying to figure this out.
Could
> > any of you give me an idea on what the heck I'm doing wrong?
> >
>
> Make folder code an integer, or add a little tool :
>
> #if ($tool.eq( $item.Folder_code, 0 ) )
>
> geir
>
> --
> Geir Magnusson Jr. [EMAIL PROTECTED]
> System and Software Consulting
> "They that can give up essential liberty to obtain a little temporary
safety
> deserve neither liberty nor safety." - Benjamin Franklin
>
>
>