Live Data Script Service

Last modified by Eleni Cojocariu on 2026/09/11 15:51

Reference

The liveData Script Service renders a Live Data, and runs Live Data queries, from a script. It is the only way to display one where Macros cannot be used, in .vm templates in particular. Prefer the "liveData" Macro whenever it can be used.

Every method throws LiveDataException when the Live Data cannot be run.

MemberReturnsWhat it does
query(Map queryConfig), query(String queryConfigJSON)A LiveDataRuns a Live Data query and returns the entries matching it, without displaying anything
effectiveConfig(Map liveDataConfig), effectiveConfig(String liveDataConfigJSON)The configuration, in the shape the argument was given inNormalizes a configuration into the format the widget expects and fills in the missing default values
execute(Map parameters), execute(Map parameters, Map advancedParameters)A rendering BlockXWiki 16.0.0+ Builds the Live Data and returns it as a Block, for code that goes on to manipulate it
render(Map parameters), render(Map parameters, Map advancedParameters)A StringXWiki 16.0.0+ Builds the Live Data and returns it rendered in the current syntax

parameters holds the same entries as the Macro parameters, and advancedParameters plays the part the Macro content plays for the Macro.

Examples

This script:

{{velocity}}
  #set($properties = {
    "id" : "users",
    "properties" : "_avatar,doc.name,first_name,last_name",
    "source" : "liveTable",
    "sourceParameters" : "className=XWiki.XWikiUsers&translationPrefix=xe.userdirectory.&last_name=Doe"
  })
  {{html}}
    $services.liveData.render($properties)
  {{/html}}
{{/velocity}}

is equivalent to:

{{liveData
  id="users"
  properties="_avatar,doc.name,first_name,last_name"
  source="liveTable"
  sourceParameters="className=XWiki.XWikiUsers&translationPrefix=xe.userdirectory.&last_name=Doe"
/}}

And, with an advanced configuration:

{{velocity}}
  #set($properties = {
    "id" : "logging",
    "properties" : "logger,level,actions",
    "source" : "liveTable",
    "sourceParameters" : "resultPage=XWiki.LoggingAdminTableJson&translationPrefix=logging.admin.livetable."
  })
  #set($advancedProperties = {
    "meta": {
      "propertyDescriptors": [
        {
          "id": "actions",
          "displayer": "html",
          "sortable": false,
          "filterable": false
        }
      ]
    }
  })
  {{html}}
    $services.liveData.render($properties, $advancedProperties)
  {{/html}}
{{/velocity}}

is equivalent to:

{{liveData
  id="logging"
  properties="logger,level,actions"
  source="liveTable"
  sourceParameters="resultPage=XWiki.LoggingAdminTableJson&translationPrefix=logging.admin.livetable."
}}{
  "meta": {
    "propertyDescriptors": [
      {
        "id": "actions",
        "displayer": "html",
        "sortable": false,
        "filterable": false
      }
    ]
  }
}{{/liveData}}

FAQ

Which method displays a Live Data?

render, whose result is the Live Data in the current syntax; execute returns the rendering Block instead, for code going on to manipulate it.

How do I pass the advanced configuration?

As the second argument of render or execute, which plays the part the Macro content plays for the Macro.

How do I inspect the configuration that will be applied?

By calling effectiveConfig, which normalises a configuration and adds the missing default values.

Can I fetch the entries without displaying them?

Yes, with query, which runs a Live Data query and returns the matching entries.

Related

Get Connected