Changes for page Scripting

Last modified by Simon Urli on 2023/10/10

<
From version < 49.3 >
edited by Vincent Massol
on 2016/07/01
To version < 50.1 >
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,18 @@
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 +{{velocity}}
311 +## Setting some script binding in Velocity
312 +#set($myvar = "toto")
313 +{{/velocity}}
314 +
315 +{{groovy}}
316 +// Lets use the script binding that has been set in previous script
317 +print myvar
318 +{{/groovy}}
319 +
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