LM
2014-03-17 17:38 GMT+01:00 Thomas Mortagne <thomas.mortagne(a)xwiki.com>om>:
The cleanest is probably to write a script service in
Groovy, see
http://extensions.xwiki.org/xwiki/bin/view/Extension/Create+a+component+usi…
for an example.
On Mon, Mar 17, 2014 at 5:31 PM, Matthias Albert <matthias.albert(a)gmx.de>
wrote:
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.albert(a)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(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
--
Matthias Albert
Rastatter Straße 26
76199 Karlsruhe
Tel. +49 (0)721 885744
Email: matthias.albert(a)posteo.de
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
--
Thomas Mortagne
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users