Wiki source code of Live Data Script Service
Last modified by superadmin on 2026/11/25 21:39
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | The ##liveData## Script Service is the only way to display one where Macros cannot be used, in ##.vm## templates in particular. Prefer the [["liveData" Macro>>doc:documentation.xs.user.livedata.display-data.macro.WebHome]] whenever it can be used. | ||
| 2 | |||
| 3 | Every method throws ##LiveDataException## when the Live Data cannot be run. | ||
| 4 | |||
| 5 | |=Member|=Returns|=What it does | ||
| 6 | |##query(Map queryConfig)##, ##query(String queryConfigJSON)##|A ##LiveData##|Runs a Live Data query and returns the entries matching it, without displaying anything | ||
| 7 | |##effectiveConfig(Map liveDataConfig)##, ##effectiveConfig(String liveDataConfigJSON)##|The configuration, in the shape the argument was given in|Normalizes a [[configuration>>doc:documentation.xs.dev.livedata.configuration.WebHome]] into the format the widget expects and fills in the missing default values | ||
| 8 | |##execute(Map parameters)##, ##execute(Map parameters, Map advancedParameters)##|A rendering ##Block##|Builds the Live Data and returns it as a ##Block##, for code that goes on to manipulate it | ||
| 9 | |##render(Map parameters)##, ##render(Map parameters, Map advancedParameters)##|A ##String##|Builds the Live Data and returns it rendered in the current syntax | ||
| 10 | |||
| 11 | ##parameters## holds the same entries as the [[Macro parameters>>doc:documentation.xs.user.livedata.display-data.macro.WebHome]], and ##advancedParameters## plays the part the Macro content plays for the Macro. | ||
| 12 | |||
| 13 | == Examples == | ||
| 14 | |||
| 15 | This script: | ||
| 16 | |||
| 17 | {{code language="none"}} | ||
| 18 | {{velocity}} | ||
| 19 | #set($properties = { | ||
| 20 | "id" : "users", | ||
| 21 | "properties" : "_avatar,doc.name,first_name,last_name", | ||
| 22 | "source" : "liveTable", | ||
| 23 | "sourceParameters" : "className=XWiki.XWikiUsers&translationPrefix=xe.userdirectory.&last_name=Doe" | ||
| 24 | }) | ||
| 25 | {{html}} | ||
| 26 | $services.liveData.render($properties) | ||
| 27 | {{/html}} | ||
| 28 | {{/velocity}} | ||
| 29 | {{/code}} | ||
| 30 | |||
| 31 | is equivalent to: | ||
| 32 | |||
| 33 | {{code language="none"}} | ||
| 34 | {{liveData | ||
| 35 | id="users" | ||
| 36 | properties="_avatar,doc.name,first_name,last_name" | ||
| 37 | source="liveTable" | ||
| 38 | sourceParameters="className=XWiki.XWikiUsers&translationPrefix=xe.userdirectory.&last_name=Doe" | ||
| 39 | /}} | ||
| 40 | {{/code}} | ||
| 41 | |||
| 42 | And, with an advanced configuration: | ||
| 43 | |||
| 44 | {{code language="none"}} | ||
| 45 | {{velocity}} | ||
| 46 | #set($properties = { | ||
| 47 | "id" : "logging", | ||
| 48 | "properties" : "logger,level,actions", | ||
| 49 | "source" : "liveTable", | ||
| 50 | "sourceParameters" : "resultPage=XWiki.LoggingAdminTableJson&translationPrefix=logging.admin.livetable." | ||
| 51 | }) | ||
| 52 | #set($advancedProperties = { | ||
| 53 | "meta": { | ||
| 54 | "propertyDescriptors": [ | ||
| 55 | { | ||
| 56 | "id": "actions", | ||
| 57 | "displayer": "html", | ||
| 58 | "sortable": false, | ||
| 59 | "filterable": false | ||
| 60 | } | ||
| 61 | ] | ||
| 62 | } | ||
| 63 | }) | ||
| 64 | {{html}} | ||
| 65 | $services.liveData.render($properties, $advancedProperties) | ||
| 66 | {{/html}} | ||
| 67 | {{/velocity}} | ||
| 68 | {{/code}} | ||
| 69 | |||
| 70 | is equivalent to: | ||
| 71 | |||
| 72 | {{code language="none"}} | ||
| 73 | {{liveData | ||
| 74 | id="logging" | ||
| 75 | properties="logger,level,actions" | ||
| 76 | source="liveTable" | ||
| 77 | sourceParameters="resultPage=XWiki.LoggingAdminTableJson&translationPrefix=logging.admin.livetable." | ||
| 78 | }}{ | ||
| 79 | "meta": { | ||
| 80 | "propertyDescriptors": [ | ||
| 81 | { | ||
| 82 | "id": "actions", | ||
| 83 | "displayer": "html", | ||
| 84 | "sortable": false, | ||
| 85 | "filterable": false | ||
| 86 | } | ||
| 87 | ] | ||
| 88 | } | ||
| 89 | }{{/liveData}} | ||
| 90 | {{/code}} |