On Mon, Dec 19, 2011 at 7:33 PM, Eugen Colesnicov <ecolesni...@gmail.com> wrote: > > Thomas Mortagne wrote >> >> ... What this script is doing >> is to register a java object created with groovy, your velocity will >> never be called when an event is received. >> >> Basically what happen: >> * when you view the page: a java listener is created and registered in >> groovy and your velocity is executed but onEvent is not called >> * when an event is received: onEvent of previously registred java >> object is called and nothing else, the script is not executed >> >> So if you need to do something when an event is received you need to >> do it fully in the onEvent method. >> > > Thanks Thomas! > As I understand, I should include all my planned script actions inside > groovy script (same as groovy script make changes in a title of source > page)... > According to this, I have another question. I should include ALL my actions > inside this onEvent object? For example, can I have on another page > something like macros (like velocity macros) and everytime, when I need > (when onEvent is called) - call this macros from onEvent object and execute > this? This is can be helpful if I need to repeat (when onEvent received) > some actions (for example - change title not only for source page, but for > all pages of a some class). If I can - it is possible to call velocity > macros, or all like this procedures should be written on groovy?
There is some possible hack to call velocity script from groovy but would be a lot easier to do pure groovy actually. If you want to repeat a task you should add a groovy method, for example onEvent itself is a method you can call it with parameters and it also can return an object which is a lot better that wiki macro in this context. Wiki macro are really targeting display and are really not supposed to be use as methods. To summarize: yes I think you will have to do learn some groovy and after some time you will see that it's a lot better than velocity for a use case like that where you don't have anything to display. You can take a look at http://groovy.codehaus.org/Beginners+Tutorial which seems pretty nice. You should get started pretty quickly, groovy is really easy for someone who already did programming in any other language. > > -- > Best regards > Eugen Colesnicov! > > -- > View this message in context: > http://xwiki.475771.n2.nabble.com/Interacting-between-groovy-velocity-script-tp7107913p7109241.html > Sent from the XWiki- Users mailing list archive at Nabble.com. > _______________________________________________ > users mailing list > users@xwiki.org > http://lists.xwiki.org/mailman/listinfo/users -- Thomas Mortagne _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users