Hi Neils, Many thanks for reporting this issue :) I have broken down your JIRA issue ( http://jira.xwiki.org/jira/browse/XAWMB-2) into two separate issues and moved them to correct projects / components as below: http://jira.xwiki.org/jira/browse/XWIKI-4140 (Fixed in 2.0M3) http://jira.xwiki.org/jira/browse/XWIKI-4141 And while fixing XWIKI-4140 I encountered another bug (not related to your JIRA) which I reported as: http://jira.xwiki.org/jira/browse/XE-475 About XWIKI-4141, you can use the {{groovy}} macro instead for now. - Asiri PS: The code in your Macros.GroovyRandom wiki macro is: {{script language=groovy}}xwiki.generateRandomString(xcontext.macro.params.size){{/script}} I had to change this to the following to make it work: {{script language=groovy}}println(xwiki.xwiki.generateRandomString(Integer.parseInt(xcontext.macro.params.size))){{/script}} On Mon, Aug 10, 2009 at 6:21 AM, Niels Mayer <[email protected]> wrote:
Also, by way of comparison, the "multiple invocation" bug doesn't happen using the "1.0 way" in a "2.0" document, without wiki-macro-bridge, using $xwiki.parseGroovyFromPage(). Is there a 2.0 equivalent for $xwiki.parseGroovyFromPage() method suggested by
http://platform.xwiki.org/xwiki/bin/view/DevGuide/GroovyClassHelloWorldTutor... ?
http://jira.xwiki.org/jira/browse/XAWMB-2?focusedCommentId=43681&page=com.at... FYI, here, I demonstrate a "regular non macro bridge" way of invoking groovy in a 2.0 document. It doesn't have the same issues with only outputting the first instance results:
== Testing parseGroovyFromPage("TestClass1") With 2.0 Syntax ==
Note that [[TestClass1?viewer=code]] is in 1.0 Syntax, per [[ http://platform.xwiki.org/xwiki/bin/view/DevGuide/GroovyClassHelloWorldTutorial]<http://platform.xwiki.org/xwiki/bin/view/DevGuide/GroovyClassHelloWorldTutorial%5D> ]. Is there a 2.0 syntax for $xwiki.parseGroovyFromPage()? ==== Initialize $groovyObject ==== {{velocity}} #set($groovyObject = $xwiki.parseGroovyFromPage("TestClass1")) $groovyObject.setObjects($xwiki, $context) {{/velocity}} ==== First Call $groovyObject.helloWorld() ==== {{velocity}}$groovyObject.helloWorld(){{/velocity}} ==== Second Call $groovyObject.helloWorld() ==== {{velocity}}$groovyObject.helloWorld(){{/velocity}} ==== Third Call $groovyObject.helloWorld() ==== {{velocity}}$groovyObject.helloWorld(){{/velocity}} ==== Fourth Call $groovyObject.helloWorld() ==== {{velocity}}$groovyObject.helloWorld(){{/velocity}} ==== Fifth Call $groovyObject.helloWorld() ==== {{velocity}}$groovyObject.helloWorld(){{/velocity}} ==== Sixth Call $groovyObject.helloWorld() ==== {{velocity}}$groovyObject.helloWorld(){{/velocity}} ==== Seventh Call $groovyObject.helloWorld() ==== {{velocity}}$groovyObject.helloWorld(){{/velocity}}
Produces
Testing parseGroovyFromPage("TestClass1") With 2.0 Syntax Note that TestClass1 is in 1.0 Syntax, per
http://platform.xwiki.org/xwiki/bin/view/DevGuide/GroovyClassHelloWorldTutor... . Is there a 2.0 syntax for $xwiki.parseGroovyFromPage()?Initialize $groovyObject First Call $groovyObject.helloWorld() Hello World:0 Second Call $groovyObject.helloWorld() Hello World:1 Third Call $groovyObject.helloWorld() Hello World:2 Fourth Call $groovyObject.helloWorld() Hello World:3 Fifth Call $groovyObject.helloWorld() Hello World:4 Sixth Call $groovyObject.helloWorld() Hello World:5 Seventh Call $groovyObject.helloWorld() Hello World:6
With the class defined in a 1.0 document:
/* Groovy Class Called by [Groovy.VelocityCallingTestClass1] #* */
class groovyClass {
def xwiki; def context; def call_count = 0;
void setObjects(xwiki, context) { setXWiki(xwiki); setContext(context); }
void setXWiki(xwiki) { this.xwiki = xwiki; }
void setContext(context) { this.context = context; }
String helloWorld() { return "Hello World:" + call_count++; } }
/* *# */
Niels http://nielsmayer.com _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs