Hi Again, On Fri, Mar 19, 2010 at 5:16 PM, Asiri Rathnayake < [email protected]> wrote:
Hi Alaina,
On Fri, Mar 19, 2010 at 4:46 PM, Alaina <[email protected]>wrote:
HI everyone,
I still think the behavior of the groovy script variable doc in a xwiki macro is not as intended. But I am using the following workaround.
Sorry for not looking into this earlier. I'm a bit stuck on some other issues.
Will look into this issue and report a JIRA as soon as I get some free time.
Thanks for raising the issue :)
- Asiri
Put the groovy code in a groovy class stored in a different wiki page (Macros.CiteGroovyClass) . There is documentation here (
http://platform.xwiki.org/xwiki/bin/view/DevGuide/GroovyClassHelloWorldTutor... ) on how to do that. Then the following velocity code in the macro definition will give the correct doc Object to the groovy code.
{{velocity}} #set($groovyObject = $xwiki.parseGroovyFromPage("Macros.CiteGroovyClass")) $groovyObject.setObjects($xwiki, $doc, $context) $groovyObject.process() {{/velocity}}
Can you try something like: {{groovy}} def currentDoc = xcontext.vcontext.doc; {{/groovy}} (in macro code) I'm just guessing, need to investigate later. - Asiri