Got it. Apparently, it was a string value. $MathTool.toInteger() did the trick.
Thanks for the assist, Christoph. Have a great day. Gary Catlin On Thu, Nov 4, 2010 at 2:08 PM, <apa...@recks.org> wrote: > Hi, > > if > > $mrank returns a number from 1 to 70 >> > this still might be a string or any java Object who's toString() is > returning something that looks like 1 to 70. > > > $mrank.class.name does not return anything. >> > It should. It is the same as: > $mrank.getClass().getName() > Maybe because of a secure Ueberspector it is not returning anything > [inhibiting getClass()]. > > You can try some further things: > a) print something like "$mrank" to ensure there is no whitespace around. > b) check your application (java) sources for what is within your $Array and > $element, ensure the methods are public and that $element.Rank is an int or > Number > c) add a tool that does the numeric comparison (e.g. > http://velocity.apache.org/tools/releases/2.0/javadoc/org/apache/velocity/tools/generic/MathTool.html), > note that since Velocity 1.5 it should support comparing different number > types. > d) check and report to this list the velocity version youre using. > > My 2c, > Christoph > > > Gary Catlin on 2010-11-04 18:49 wrote: > >> Thanks for the reply, Christoph. >> >> $mrank returns a number from 1 to 70 >> $mrank.class.name does not return anything. >> >> I had tried the #elseif cascade originally, but since the comparisons were >> not working, I simplified in an attempt to narrow down the problem. >> Unfortunately, it hasn't. Yes, everthing ends up in the #else branch using >> that method. Still no luck, though. >> >> gmc >> >> On Thu, Nov 4, 2010 at 11:06 AM,<apa...@recks.org> wrote: >> >> Hi, >>> >>> please check what your $mrank object contains: >>> print it out: $mrank >>> check the class of it: $mrank.class.name >>> >>> Also you would profit from an #elsif cascade. >>> >>> #if ($mrank<= 30) #set ($n = $MS1.add($record)) >>> #elsif ($mrank>= 60) #set ($n = $MS3.add($record)) >>> #else #set ($n = $MS2.add($record)) >>> #end >>> Here, if the comparisons where not possible, due to the class behind >>> $mrank, everything would end up in the #else branch. >>> >>> OTOH... some purists would cry-out that templates are not the place to >>> code >>> business-logic... >>> >>> Hope this helps, kind regards, >>> Christoph >>> >>> >>> Gary Catlin on 2010-11-04 14:38 wrote: >>> >>> Hello All, >>>> >>>> Does anyone know why the code below is not working as intended? I am >>>> attempting to group the records in $Array by the value of $Array.Rank. I >>>> have examined the contents and $Array.Rank returns values between 1 and >>>> 70, >>>> as expected. The conditions in my 3 #if statements don't seem to be >>>> getting >>>> activated, and $MS1/2/3 are empty. >>>> >>>> Thank you. >>>> >>>> #set ($MS1 = []) >>>> #set ($MS2 = []) >>>> #set ($MS3 = []) >>>> #set ($mrank = 0) >>>> >>>> #foreach ($element in $SortTool.sort($Array, ["rank", "name"])) >>>> #set ($mrank = $element.Rank) >>>> #set ($record = { 'Rank' : $element.Rank, 'Title' : $element.Name } >>>> ) >>>> #if ($mrank<= 30) #set ($n = $MS1.add($record)) #end >>>> #if ($mrank>= 60) #set ($n = $MS3.add($record)) #end >>>> #if ($mrank> 30&& $mrank< 60) #set ($n = $MS2.add($record)) >>>> #end >>>> ## #set ($n = $MS1.add($record)) ## debug, commented out >>>> #end >>>> >>>> Gary Catlin >>>> >>>> >>>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org >>> For additional commands, e-mail: user-h...@velocity.apache.org >>> >>> >>> >> > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org > For additional commands, e-mail: user-h...@velocity.apache.org > >