<
From version < 49.3 >
edited by Vincent Massol
on 2016/07/01
To version < 50.2 >
edited by Vincent Massol
on 2016/09/17
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -293,7 +293,7 @@
293 293  
294 294  Most JSR223 based scripting languages reinject the created variable in the current ##ScriptContext## which means you can define a variable in a Groovy script and reuse it in a following Python script for example.
295 295  
296 -Since 4.1M2 a bridge has been written for Velocity (which is not based on JSR223) to allow it to access the current ScriptContext variable so you can do things like:
296 +Since the Velocity implementation isn't based on JSR223, we have also set up a bridge so that Velocity scripts can access the current ##ScriptContext## variables. This allows for example to define a variable in a Groovy script and then reuse it in a Velocity one:
297 297  
298 298  {{code}}
299 299  {{groovy}}
... ... @@ -305,6 +305,20 @@
305 305  {{/velocity}}
306 306  {{/code}}
307 307  
308 +Starting with XWiki 8.3 the Velocity bridge has been improved and it's now possible to do the opposite, i.e. define a variable in Velocity and access it from another scripting language. For example:
309 +
310 +{{code}}
311 +{{velocity}}
312 +## Setting some script binding in Velocity
313 +#set($myvar = "toto")
314 +{{/velocity}}
315 +
316 +{{groovy}}
317 +// Lets use the script binding that has been set in previous script
318 +print myvar
319 +{{/groovy}}
320 +{{/code}}
321 +
308 308  Note that you can also share variables by setting them in the XWiki Context (##xcontext## binding).
309 309  
310 310  = Scripting In XWiki Syntax 1.0 =

Get Connected