Script Macro

Executes a script, implementing the JSR-223 API.

Usage

{{script language="scriptengine"}}
print "some" + " " + "script" + " " + "content"
{{/script}}

The xwiki and xcontext variables are defined by default and represent the XWiki and Context API objects.

Parameters Definition

NameOptionalAllowed valuesDefault valueDescription
languageyesthe identifier of the JSR 223 engine Indicates which engine to use to execute the provided script. 
outputyestrue/falsetrueIndicates the output result has to be inserted back in the document.
wikiyestrue/falsetrueindicates if the result of the script execution has to be parsed by the current wiki parser. If not, it is put into a verbatim block.
jarsyescomma-separated list of JARs that will be added to the script execution class loadernoneSee below

Specifying Extra JARs

If you have programming rights, it is possible to add JARs that will be available when executing the script by using the jars parameters. Their format is a comma-separated list of entries:

  • a URL: [[http://server/path/to/some.jar]]
  • a reference to a JAR attachment located on the current page: [[attach:some.jar]]
  • a reference to a JAR attachment located on another page: [[attach:wiki:space.page@some.jar]]
  • a reference to all jars located on a given page: [[attach:wiki:space.page]]

Bindings

Some bindings are automatically provided:

NameClassDescription
xwikicom.xpn.xwiki.api.XWikiRepresents the XWiki object.
xcontextcom.xpn.xwiki.api.ContextRepresents the Context of the request.
requestcom.xpn.xwiki.web.XWikiRequestThe servlet request. Generally used to get URL parameters.
responsecom.xpn.xwiki.web.XWikiResponseThe servlet response.
doccom.xpn.xwiki.api.DocumentThe current document.
cdoccom.xpn.xwiki.api.DocumentThis variable represent the current default document (not the translated) from which to access the Comments, Objects and Attachments.
tdoccom.xpn.xwiki.api.DocumentIt represents the translated document matching the requested language
utilcom.xpn.xwiki.api.UtilUtility APIs available to scripting environments under the util variable.
msgcom.xpn.xwiki.web.XWikiMessageToolProvides a internationalization service based on key/property values.
syntaxFactoryorg.xwiki.rendering.syntax.SyntaxFactoryAllows the creation of a wiki syntax that the user can use to enter wiki content.
officeimporterPuts a reference to Office Importer in newly created velocity contexts.

Related Pages

Search this space