[xwiki-users] Arrays in Groovy and Velocity
Hi all, is it possible to fill an array in groovy, return it to velocity and manipulate the array in velocity ? e.g.: filling a groovy_array with results from sql.eachRow Now, when I'm trying to access it with velocity, the whole array is just one string and I can't loop through it using #foreach. Do you have any ideas what I can do ? thanks in advance Matthias
In xwiki/2.0 syntax you can do {{groovy}} xcontext.put("myvar", [5, 6, 7, 8]) {{/groovy}} {{velocity}} #set($myvar = $xcontext.myvar) $myvar {{/velocity}} for example. You can do the same with any kind of variable between any script language since the "xcontext" binding is a map shared between all scripts of the same document and included documents. I would like to be able to do {{groovy}} myvar = [5, 6, 7, 8]) {{/groovy}} {{velocity}} $myvar {{/velocity}} some day but it's not that easy to do it cleanly yet plus we need to refactor velocity scripting to be called using JSR223 like groovy and other languages. See http://jira.xwiki.org/jira/browse/XWIKI-2806 On Tue, Oct 13, 2009 at 14:56, <[email protected]> wrote:
Hi all,
is it possible to fill an array in groovy, return it to velocity and manipulate the array in velocity ?
e.g.: filling a groovy_array with results from sql.eachRow
Now, when I'm trying to access it with velocity, the whole array is just one string and I can't loop through it using #foreach.
Do you have any ideas what I can do ?
thanks in advance Matthias
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
participants (2)
-
Matthias.Gsottberger@o2.com -
Thomas Mortagne