On 10/12/01 8:18 PM, "Terry Steichen" <[EMAIL PROTECTED]> wrote:
> I'm still having some problems with converting variables to integers so I can > perform operations on/with them. (I've got some complex displays.) In this > particular case, my Java code is doing a context.put() of a vector of vectors, > each of which holds several objects, one of which is an Integer object. The > reference (at the VTL level, inside the #foreach($entry in $entries) > directive) is $entry.elementAt(0).Price. It displays fine, but if I try to do > any operations on it (adding, multiplying, etc.), the result is (apparently) > null. I've tried $int.valueOf($entry.elementAt(0).Price), but that has the > same outcome. I've gone over both the user and dev docs again and find only a > mention that you must use integers. > > In other words, in the template: > > #set($charge = 1 * $int.valueOf($entry.elementAt(0).Price)) does *not* work. > #set($charge = $int.valueOf($entry.elementAt(0).Price)) does *not* work > #set($charge = $entry.elementAt(0).Price) works, in the sense that it's value > is not null. > I am going to assume that $entry.elementAt(0).Price is supposed to be a java.lang.String and $int is a java.lang.Integer. I suspect that Price isn't, as the line #set($charge = $int.valueOf($entry.elementAt(0).Price)) Appears at first glance to be perfectly valid. What does the velocity.log say - there should be something in there... > Please give me some idea of how to handle this stuff without introducing too > much logic into the template and I'll be happy to write it up for others. I don't think that's the issue... > Regards, > > Terry > > PS: Someone suggested my earlier question would better fit into the users' > (rather than developers') group. I'm staying with the developer's list > because these questions seem to be deeper than template editing (but > admittedly more specific and pragmatic than deep 'inner guts' stuff). > So far, this is perfectly acceptable stuff for -user. Geir -- Geir Magnusson Jr. [EMAIL PROTECTED] System and Software Consulting "Whoever would overthrow the liberty of a nation must begin by subduing the freeness of speech." - Benjamin Franklin
