Wiki source code of Scripting

Version 1.6 by vmassol on 2006/12/11

Show last authors
1 1 Scripting
2
3 XWiki integrates both Velocity and Groovy scripting. Together, these two mechanisms allow you to create basic to complex web applications at the XWiki page (or view) layer without the need for compiling code or deploying software components. In other words, you can use Velocity and Groovy script syntax in addition to wiki and HTML syntax as the contents of an XWiki page.
4
5 1.1 XWiki's Velocity API
6
7 The concept of the 'context' is central to Velocity. The context is a 'carrier' of data between the Java layer of the XWiki engine and the template or page layer. The programmers of the XWiki core have gathered objects of various types and placed them in the Velocity context. These objects, and their methods and properties, are accessable via template elements called references and effectively form an API for XWiki.
8
9 The API is documented in Javadoc format and can be accessed here: [XWiki API Javadoc>http://build.xpertnet.biz/doc/api/com/xpn/xwiki/api/Api.html]. If you are not familiar with Java or object oriented programming, you will probably be confused by the API documentation. It is not within the scope of our documentation to teach you all the details about Velocity, Java, or object oriented programming. You can find all of that information already online. Instead, we provide only a high-level overview in [Basic Velocity Scripting Tutorial>Basic Velocity]; it will give you a good sense for how Velocity scripting works in XWiki. You should then refer to the [Velocity User Guide>http://jakarta.apache.org/velocity/docs/user-guide.html#What%20is%20Velocity] as an ongoing reference. Finally, you can explore the page code found throughout the [Code Zone>Code.WebHome] area to see how others have figured out how to achieve a variety of results.
10
11 You can access in your velocity script to :
12 * The current document: *\$doc*, see the [XWiki Javadoc 0.9.840>http://build.xpertnet.biz/doc/api/com/xpn/xwiki/api/Document.html] [XWiki Javadoc for code in SVN>http://build.xpertnet.biz/doc/nightly/api/com/xpn/xwiki/api/Document.html]
13 * The Context of the request: *\$context*, see the [XWiki Javadoc 0.9.840>http://build.xpertnet.biz/doc/api/com/xpn/xwiki/api/Context.html] [XWiki Javadoc for code in SVN>http://build.xpertnet.biz/doc/nightly/api/com/xpn/xwiki/api/Context.html]
14 * the XWiki Object: *\$xwiki*, see the [XWiki Javadoc 0.9.840>http://build.xpertnet.biz/doc/api/com/xpn/xwiki/api/XWiki.html] [XWiki Javadoc for code in SVN>http://build.xpertnet.biz/doc/nightly/api/com/xpn/xwiki/api/XWiki.html]
15
16 You can also [use HQL to query the XWiki database>velocityHqlExamples] from your velocity scripts.
17
18 1.1 XWiki's Groovy API
19
20 Currently Groovy is only allowed for admins of a wiki (or users having the 'programming' right).
21
22 * Groovy examples: See [Dev.XWikiGroovy], [Dev.GroovyXML]
23 * [Feeling Groovy>http://www-128.ibm.com/developerworks/java/library/j-alj08034.html]
24
25 * [MVC programming with Groovy templates>http://www-128.ibm.com/developerworks/java/library/j-pg02155/]
26 * [Guillaume Laforge on Groovy, XWiki etc.>http://www.vanwardtechnologies.com/glaforge01.php]
27
28 <span style="background-color:yellow">TO DO: We need to move all of the Groovy pages from the "Dev" Web Space to this area. Then, with all the Velocity and Groovy docs in this Web Space, we can reorganize and cross reference and such.</span>

Get Connected