Thanks for your response.

But how can I create o "global" binding to an instance of my class? The
background is: I would like to avoid programming rights required, and so
I believe, I need Velocity and not a bit of Groovy in the referencing page.

In fact, I need one instance of the groovy class and references in
Velocity from several pages.

How is this possible?
Matthias

Am 16.03.2014 12:20, schrieb Thomas Mortagne:
> It's not really relayed to Groovy, Velocity cannot work with statics.
> 
> You will have to work with non static methods and assign one script
> binding to an instance of your groovy class like in:
> 
> {{groovy}}
> class MyClass {
>   myFunction(out) {
>     out.println "hello world"
> }
> 
> mytool = new MyClass()
> {{/groovy}}
> 
> {{velocity}}
> $mytool.myFunctionnction(out)
> {{/velocity}}
> 
> On Sat, Mar 15, 2014 at 9:12 PM, Matthias Albert <matthias.alb...@gmx.de> 
> wrote:
>> Hi all,
>>
>> after I managed to write a groovy class with a static method within a
>> groovy block:
>> {{groovy}}
>> class MyClass {
>>   static myFunction(out) {
>>     out.println "hello world"
>> }
>>
>> MyClass.myFunction(out)
>> {{/groovy}}
>>
>> I would like to invoke thos static groovy class function from within a
>> Velocity block:
>> ${MyClass.myFunction(out)}
>>
>>
>> But unfortunately, this does not work. Nothing will be displayed.
>>
>> Has anybody an idea for help?
>>
>> Thanks Matthias
>>
>> _______________________________________________
>> users mailing list
>> users@xwiki.org
>> http://lists.xwiki.org/mailman/listinfo/users
> 
> 
> 

-- 
Matthias Albert
Rastatter Straße 26
76199 Karlsruhe
Tel. +49 (0)721 885744
Email: matthias.alb...@posteo.de

_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to