Ok I think I know...

Actually the message is printed in the console.

You see something in the page only if you print in the global scope because 
this is what gets returned by script evaluation. Calling “println” in a class 
doesn’t return anything in the evaluation and thus you don’t see anything.

That’s why the examples at 
http://extensions.xwiki.org/xwiki/bin/view/Extension/Groovy+Macro work.

Thanks
-Vincent




On 18 Dec 2014 at 22:10:54, Bryn Jeffries 
([email protected](mailto:[email protected])) wrote:  

> Why does a page containing just the following produce no output?:  
>  
> {{groovy}}  
> class Callee {  
> void hello() {  
> println "hello, world"  
> }  
> }  
> c = new Callee()  
> c.hello()  
> {{/groovy}}  

Actually this is a good question! I don’t know…  

I’ve tried it in the groovy web console and it works so it’s something specific 
to the way XWiki uses Groovy. Could be because that we use the Scripting API 
(JSR 223) to access Groovy.  

It probably means that the output is not wired when inside the class scope but 
I’m not sure why…  

The method is invoked for since the following works fine:  

{{groovy}}  
class Callee {  
 String hello() {  
   return "hello, world"  
 }  
}  
c = new Callee()  
println c.hello()  
{{/groovy}}  

If someone has an idea…  

Thanks  
-Vincent  

> I have programming rights, and running scripts in general works fine. It's 
> just when I try to invoke a method from a locally defined class that I hit 
> problems.  


_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to