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.

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
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to