Hi Alaina,

On Fri, Mar 19, 2010 at 4:46 PM, Alaina <xw...@ursus.otherinbox.com> 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/GroovyClassHelloWorldTutorial
> ) 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}}
>
> Thanks for all your help,
> --Alaina
>
> >> That is indeed the case for velocity. However if I am using groovy I
> >> get different results.
> >>
> >> I have the following XWiki Macro groovy-test in Page GroovyTest
> >>
> >> {{velocity}}
> >> {{/velocity}}
> >> {{velocity}}
> >> $doc.getAttachmentURL("test.dat")
> >> {{/velocity}}
> >> {{groovy}}
> >> print("{{html}}");
> >> print( doc.getAttachmentURL("test.dat") );
> > print( xcontext.doc.getAttachmentURL("test.dat",xcontext.getContext());
> >> println("{{/html}}");
> >> {{/groovy}}
> >>
> >> if I put
> >> {{groovy-test /}}
> >> in the body of the page I get the following output
> >>
> >> /xwiki/bin/download/Macros/GroovyTest/test.dat
> >> /xwiki/bin/download/Macros/GroovyTest/test.dat
> > /xwiki/bin/download/Macros/GroovyTest/test.dat
> >>
> >> no surprise. However, If i put the same page body int the page
> >> GroovyTestExternal the output is
> >>
> >> /xwiki/bin/download/Macros/GroovyTestExternal/test.dat
> >> /xwiki/bin/download/Macros/GroovyTest/test.dat
> > /xwiki/bin/download/Macros/GroovyTest/test.dat
> >>
> >> thus the difference is with the macro language. What should I use in
> >> order to get the expected output (GroovyTestExternal) in groovy?
> >>
> >> Thanks so much,
> >> --Alaina
> >>
> >>
> >
> _______________________________________________
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to