<
From version < 8.1 >
edited by Vincent Massol
on 2008/03/03
To version < 8.2 >
edited by Vincent Massol
on 2008/10/31
>
Change comment: Moved content from Bruno here since it seems a better place

Summary

Details

Page properties
Content
... ... @@ -18,7 +18,6 @@
18 18  
19 19  To include Velocity scripts in other Velocity scripts, see [How to include a velocity page into another page>DevGuide.IncludeInVelocity].
20 20  
21 -
22 22  1.1 XWiki's Groovy API
23 23  
24 24  Currently Groovy is only allowed for admins of a wiki (or users having the 'programming' right).
... ... @@ -28,4 +28,27 @@
28 28  * [MVC programming with Groovy templates>http://www-128.ibm.com/developerworks/java/library/j-pg02155/]
29 29  * [Guillaume Laforge on Groovy, XWiki etc.>http://www.stelligent.com/content/view/44/71/]
30 30  
30 +1.1.1 Groovy Example
31 31  
32 +The following example demonstrates how to use a groovy script directly inside your page. This example performs a reverse DNS lookup from the velocity variable <tt>\$address</tt> and store the result into the variable <tt>\$hostname</tt>.
33 +
34 +{code}
35 +#set ($address = "172.20.12.61")
36 +
37 +IP Address: $address
38 +
39 +<%
40 +
41 +import java.net.InetAddress;
42 +
43 +vcontext = context.get("vcontext");
44 +hostname = vcontext.get("address");
45 +
46 +InetAddress addr = InetAddress.getByName(hostname);
47 +hostname = addr.getHostName().toLowerCase();
48 +
49 +%>
50 +
51 +Hostname: $hostname
52 +{code}
53 +

Get Connected