velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Leidigh <>
Subject String to Int for array index
Date Thu, 12 Dec 2002 16:48:11 GMT
I have a var I pass in a hidden field from one vm to the next.  The var, 
which is a number is being intepreted by velocity as a string but I want 
to use it to index a local array?  Ex:


<html>... yada yada
#set ($arr = ["One", "Two"])
#set ($x = 1)
$arr.get($x) #* Works and prints "One" *#
<input type="hidden" name="val" value="$x">


#set ($arr = ["One", "Two"])
$myBean.val  #*  Prints "1" *#

$arr.get( $myBean.val ) #* FAILS, Prints: "$arr.get( $myBean.val )" *#

I know the simple answer is  make sure the  bean/servlet does the 
conversion internally but I am dealing with a closed solution which 
passes me form vars from one page to the next and I have no control 
until I get to the next vm.  I think maybe a tool is my only way to 
go......can anyone help?

Jason Leidigh

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

View raw message