On Tue, Nov 25, 2014 at 9:48 AM, Adrien Moi <[email protected]> wrote:
> Hello
> I'm using the "include macro" to transfer some information between the 
> different documents of my xwiki, but somehow I can't transfer any class. When 
> I try this code :
>
> First page :
>
> {{groovy}}
> xy=2;
> public class Souris {
> public String Name;
> public Souris(){
> Name="Jerry";
> }
> }
>
> Souris Verte = new Souris();
> {{/groovy}}

In Groovy "Souris Verte" syntax make it a local variable. To allow it
ot be used in another script you need to remove the type declaration
(there is maybe another way that I don't know, I'm not really a Groovy
expert) it so that would be:

{{groovy}}
xy=2;
public class Souris {
public String Name;
public Souris(){
Name="Jerry";
}
}

Verte = new Souris();
{{/groovy}}

>
> Second page :
>
> {{include reference="First page"/}}

Be careful when you put two macros in the same paragrap it will
actually generate a paragraph with two inline macros so make sure to
separate inclue and the first groovy macro like you separated the two
groovy macros.

> {{groovy}}
> println(xy);
> {{/groovy}}
>
> {{groovy}}
> println(Verte.Name)
> {{/groovy}}
>
> the first groovy macro runs well and displays
> 2
> as predicted, but the second one doesn't work. Why ? And how can I make it 
> work?
>
> Thanks for the advice !
>
> Adrien
>
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users



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

Reply via email to