groovy scripting

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

groovy scripting

Duke Tantiprasut

Hi All,

I'm starting to have a look at groovy scripting in xwiki and have a couple
of basic questions:

In the example below (from xwiki.org)

<%
def foo(list, value)
{
    println "Calling function foo() with param ${value} <br>";
    list << value;
}

x = [];
foo(x, 1);
foo(x, 2);
foo(x, 3);
foo(x, 4);

println "Creating list ${x}";
%>

1) does the groovy variable ${value} get translated before the velocity
${value} (if defined) or vice versa?

2) I tried the example and get the following result:

Calling function foo() with param 1
Calling function foo() with param 2
Calling function foo() with param 3
Calling function foo() with param 4
Creating list 1, 2, 3, 4?

where the "1, 2, 3, 4?" is a link to "1,+2,+3,+4". I assume the output from
groovy is then processed by the xwiki syntax?

Thanks

Duke




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: groovy scripting

kaaloo
Hi Duke,

From my understanding, Velocity gets processed before Groovy so any
Velocity syntax in Groovy code will get evaluated by Velocity which
might give some strange behavior.  For instance the following code:

<%
value = 20
println "Value : ${value}"
%>

#set($value="10")

<%
value = 30
println "Value : ${value}"
%>

Gives the following output:

Value : 20

Value : 10

Because the first time ${value} evaluates to "${value}" and the second
time to "10".  Then Groovy does a second pass.

Luis.

On 9/8/05, Duke Tantiprasut <[hidden email]> wrote:

>
> Hi All,
>
> I'm starting to have a look at groovy scripting in xwiki and have a couple
> of basic questions:
>
> In the example below (from xwiki.org)
>
> <%
> def foo(list, value)
> {
>     println "Calling function foo() with param ${value} <br>";
>     list << value;
> }
>
> x = [];
> foo(x, 1);
> foo(x, 2);
> foo(x, 3);
> foo(x, 4);
>
> println "Creating list ${x}";
> %>
>
> 1) does the groovy variable ${value} get translated before the velocity
> ${value} (if defined) or vice versa?
>
> 2) I tried the example and get the following result:
>
> Calling function foo() with param 1
> Calling function foo() with param 2
> Calling function foo() with param 3
> Calling function foo() with param 4
> Creating list 1, 2, 3, 4?
>
> where the "1, 2, 3, 4?" is a link to "1,+2,+3,+4". I assume the output from
> groovy is then processed by the xwiki syntax?
>
> Thanks
>
> Duke
>
>
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>

--
Luis Arias
http://www.xwiki.com
http://www.innover-entreprendre.net
skype : kaaloo
+33 6 14 20 87 93 mobile



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws