<
From version < 20.2 >
edited by Caleb James DeLisle
on 2010/01/03
To version < 20.3 >
edited by Vincent Massol
on 2010/01/03
>
Change comment: Removed ":" in headers

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.CalebJamesDeLisle
1 +XWiki.VincentMassol
Content
... ... @@ -1,11 +1,11 @@
1 1  {{box cssClass="floatinginfobox" title="**Contents**"}}{{toc/}}{{/box}}
2 2  XWiki integrates [[jsr-223>>http://scripting.dev.java.net/]] scripting. [[Velocity>>http://velocity.apache.org/]], [[Groovy>>http://groovy.codehaus.org/]] and [[Python>>http://jython.sourceforge.net]] languages come bundled with XWiki while there are macros for Php and [[Ruby>>http://www.jruby.org/]] but the script engines are not bundled in order to decrease installation size. Scripting allows 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 scripting syntax in addition to wiki and HTML syntax as the contents of an XWiki page.
3 3  
4 -= XWiki Scripting API
4 += XWiki Scripting API =
5 5  
6 6  The API is documented in Javadoc format and can be accessed here: [[XWiki API Javadoc>>DevGuide.API]]. 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 Java, or object oriented programming. You can find all of that information already online. You can also explore the page code found throughout the [[Code Zone>>code:Main.WebHome]] area to see how others have figured out how to achieve a variety of results.
7 7  
8 -== [[Bindings>>code:Macros.ScriptMacro#HBindings]]
8 +== [[Bindings>>code:Macros.ScriptMacro#HBindings]] ==
9 9  
10 10  These objects are available to you in scripting languages.
11 11  * [[The current Document>>http://maven.xwiki.org/site/xwiki-core-parent/xwiki-core/apidocs/com/xpn/xwiki/api/Document.html]]: **##doc##**
... ... @@ -14,7 +14,7 @@
14 14  * [[The Response object>>http://maven.xwiki.org/site/xwiki-core-parent/xwiki-core/apidocs/com/xpn/xwiki/web/XWikiResponse.html]]: **##response##**
15 15  * [[The XWiki object>>http://maven.xwiki.org/site/xwiki-core-parent/xwiki-core/apidocs/com/xpn/xwiki/api/XWiki.html]]: **##xwiki##**
16 16  
17 -== [[XWiki Component>>code:Modules.ComponentModule]] Access:
17 +== [[XWiki Component>>code:Modules.ComponentModule]] Access ==
18 18  
19 19  You can also gain direct access to XWiki components using the following code snippet:
20 20  Also see: [[Accessing components from Groovy>>DevGuide.WritingComponents#HAccessingacomponentfromgroovy]]
... ... @@ -26,7 +26,7 @@
26 26  {{/groovy}}
27 27  {{/code}}
28 28  
29 -== XWiki Core Access:
29 +== XWiki Core Access ==
30 30  
31 31  Sometimes the XWiki Api doesn't provide the methods which you need for your application. you can gain raw access the core of XWiki but it presents an increased security risk and as such should be avoided if at all possible.
32 32  {{code language=java}}
... ... @@ -45,7 +45,7 @@
45 45  Again, these methods are only for the rare cases when functionality is not provided by the public Api and using this trick will increase the damage in the event that your script contains a security flaw which is exploited so it should be avoided when possible.
46 46  
47 47  {{id name=velocity /}}
48 -= Velocity Specific Information
48 += Velocity Specific Information =
49 49  
50 50  Velocity is the only scripting language which can be used without Administration or Programming [[AdminGuide.Access Rights]]. This means you can save velocity scripts using a username with less permission and an exploit of your script is less of a security breach. Also if you are administrating a [[virtual wiki>>AdminGuide.Virtualization]] and you don't have programming rights, you can still do scripting in Velocity.
51 51  You can [[gain access to the XWiki core>>#HXWikiCoreAccess]] from Velocity but this will require programming rights.
... ... @@ -68,12 +68,12 @@
68 68  
69 69  To include Velocity scripts in other Velocity scripts, see [[How to include a velocity page into another page>>DevGuide.IncludeInVelocity]].
70 70  
71 -== Other Velocity Variables
71 +== Other Velocity Variables ==
72 72  
73 73  {{info}}These variables can be used but are subject to change in the future.{{/info}}
74 74  
75 75  {{id name=HControllingwhethertodisplayCommentsHistoryAttachmentInformationsectionsornot /}}
76 -=== Controlling Which Sections to Display
76 +=== Controlling Which Sections to Display ===
77 77  
78 78  You can control whether to display Comments/History/Attachment/Information sections or not by setting some velocity variable to "no":
79 79  
... ... @@ -90,7 +90,7 @@
90 90  #set($docextras = [])
91 91  {{/code}}
92 92  
93 -= Groovy Specific Information
93 += Groovy Specific Information =
94 94  
95 95  Currently all non Velocity scripting languages are only allowed for administrators of a wiki (or users having the 'programming' right).
96 96  
... ... @@ -98,7 +98,7 @@
98 98  * [[Feeling Groovy>>http://www-128.ibm.com/developerworks/java/library/j-alj08034.html]]
99 99  * [[MVC programming with Groovy templates>>http://www-128.ibm.com/developerworks/java/library/j-pg02155/]]
100 100  
101 -== Groovy Example
101 +== Groovy Example ==
102 102  
103 103  The following example demonstrates how to use a groovy script to interact with velocity code in your page. This example performs a DNS lookup from the velocity variable ##$hostname## and stores the result in the variable ##$address##.
104 104  
... ... @@ -137,7 +137,7 @@
137 137  IP Address: $address
138 138  {{/code}}
139 139  
140 -= Python Specific Information
140 += Python Specific Information =
141 141  
142 142  In Python, you have all of the powers available in Groovy but the default bindings are not available due to a [[bug in Jython>>http://bugs.jython.org/issue1426]] There is a workaround snippet which manually loads the context, document, wiki object, request and response available [[here>>code:Snippets.AccessToBindingsInPythonSnippet]].
143 143  
... ... @@ -154,7 +154,7 @@
154 154  {{/python}}
155 155  {{/code}}
156 156  
157 -= Scripting In XWiki Syntax 1.0
157 += Scripting In XWiki Syntax 1.0 =
158 158  
159 159  XWiki Syntax 1.0 is rendered by an old rendering engine which is a low development priority as it will eventually be removed. Syntax 1.0 has some idiosyncrasies which were solved by syntax 2.0.
160 160  

Get Connected