yeah, the [] syntax isn't supported at this time. if you are stuck using Velocity 1.5, then you'll need to use a tool like this:
http://velocity.apache.org/tools/releases/1.4/javadoc/org/apache/velocity/tools/generic/ListTool.html Though, i recommend upgrading to 1.6-beta2, as 1.6 allows you to call many ArrayList methods on arrays, thus letting you do: #foreach( $r in [0..6] ) #foreach( $d in [0..3] ) #set( $idx = $r * 4 + $d ) $ts.get($idx) #end #end On Mon, Nov 17, 2008 at 2:04 PM, Mark Fenbers <[EMAIL PROTECTED]> wrote: > I have been using velocity for less than a year and still somewhat green. > Something new I've tried and am having trouble with is the following: > > I've vc.put(ts); where ts is defined in Java as a String array (String[]). > > In my template, I have: > > #foreach( $r in [0..6] ) > #foreach( $d in [0..3] ) > #set( $idx = $r * 4 + $d ) > $ts[$idx] > #end > #end > > This prints literally $ts[0], $ts[1], $ts[2], etc., each on a separate line. > $idx is set to the correct values. What I want to happen is that each > String array element is printed, not the literal Velocity code. Obviously, > Velocity isn't setup to refer to individual array elements -- at least, > using the Java syntax.. So what is the work-around for this? > > Mark > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
