I am not sure why you are trying to use 2 contexts rather than simply putting two objects within the same context. Perhaps that is what you really meant.
If that is what you are really trying to do then use an ArrayList, or something besides a simple array for context2. With Velocity arrays seem to work fine with #foreach($ctx1 in $context1), but not so well when you do $x[1]. However using ArrayList x, and doing x.get($i) works quite well. I am not currently using the latest version of Velocity, so perhaps this is something that was addressed in later versions. If anyone knows of an approach for correctly accessing a String array x[$i] within a velocity template (using the second syntax) I would like to see it myself. Or, if there is a FAQ on this that would be helpful. Good Luck. -----Original Message----- From: Tarun [mailto:[EMAIL PROTECTED] Sent: Thursday, June 23, 2005 12:06 AM To: [email protected] Subject: How two iterate two context in a single foreach loop hii I am using velocity view template with turbine framework. i am getting two context on the velocity template say context1 and context2. Both these contexts have an array of string and of same length. Now in a single loop i want to iterate the values of both the context. But i am not able to do that. what i was trying to do is that:- #set($counter = 0) #foreach($ctx1 in $context1) <select name="combobox"> <option value="$context2[$counter]">$ctx1</option> </select> #end Here in the foreach loop $ctx1 is returning me the exact values but the $context2[$counter] is returning me the object of the array string. so i am not able to get the values. So is there any way in which i can iterate the two context in a single foreach loop or any another way you can suggest. Thanks in Advance Tarun --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
