Live Data Sources
Reference
A Live Data source provides both the entries and what the Live Data needs in order to interact with them: which properties exist, which of them can be sorted, filtered or edited, and how each is displayed. The source Macro parameter names one by its Component hint, and sourceParameters carries the query string that source understands.
| Source | Hint | Entries come from |
|---|---|---|
| Live Table results | liveTable | Any live table results page, which makes an existing live table usable as a Live Data |
| In-line data | N/A | The Macro content itself, written as JSON |
Implementing a new source is described in Live Data Extension Points.
Live Table Source
The liveTable source exposes any live table results page as a Live Data. Adding useLiveData=true to the query string of a page holding a live table previews it as a Live Data without changing the page.
It accepts these live table parameters:
| Name | Default Value | Description |
|---|---|---|
| className | N/A | The class whose objects are listed. Its properties become the properties of the entries. |
| resultPage | XWiki.LiveTableResults | The page producing the results. |
| queryFilters | currentlanguage,hidden | The query filters applied. With the default value the content is translated to the locale of the reader, and hidden pages are listed only for readers whose profile sets "Display hidden pages" to "Yes". |
| translationPrefix | N/A | The prefix of the translation keys used for the property names. |
| template | N/A | Use this in case you have a live table with results generated from a Velocity template. The value of this parameter should match the template specified in the url live table configuration using the xpage query string. |
| hasEditMode | false | XWiki 18.7.0+ Whether the reader may switch the Live Data to Edit mode. |
| newRowLocation | N/A | XWiki 18.7.0+ Location to store pages when creating new rows. Requires a compatible row naming strategy, e.g., uuid. |
| newRowNamingStrategy | N/A | XWiki 18.7.0+ Strategy to use to generate page names when creating new rows. Right now, the only value supported is uuid which uses a random UUID for each new page and create them in the location set by newRowLocation. |
The extraParams live table parameter is deliberately unsupported: its main use is filtering, and a Live Data expresses filters generically. Migrate a Live Table to Live Data says what to do with it. A live table that built its parameters in Velocity, as in:
{{velocity}}
#set ($options = {
'className': 'ExtensionCode.ExtensionVersionClass',
'location': "${doc.space}"
})
{{liveData
id="versions"
properties="version,notes"
source="liveTable"
sourceParameters="$services.rendering.escape($escapetool.url($options), 'xwiki/2.1')"
/}}
{{/velocity}}passes them to the source the same way, once URL-encoded and escaped for the wiki syntax.
Properties from Other Classes
XWiki 18.0.0+
It is possible to specify a property from another class than the one named in className by passing a <property>_class source parameter, and it can then be filtered, sorted and edited like any other. When a displayed page holds no object of that class yet, one is created the first time the property is saved.
{{liveData properties="doc.location,doc.title,tags" source="liveTable" sourceParameters="tags_class=XWiki.TagClass&translationPrefix=platform.index."/}}In-line Data
The entries are written directly in the Macro content as JSON, together with the property descriptors saying how to display them. No source is named in that case.
{{liveData
id="movies"
properties="title,genre,releaseDate,director"
}}{
"data": {
"count": 2,
"entries": [
{
"title": "Meet John Doe",
"url": "https://www.imdb.com/title/tt0033891/",
"genre": ["Comedy", "Romance"],
"releaseDate": -904615200,
"director": "Frank Capra",
"directorURL": "https://www.imdb.com/name/nm0001008/"
},
{
"title": "Modern Times",
"url": "https://www.imdb.com/title/tt0027977/",
"genre": ["Comedy", "Drama"],
"releaseDate": -1068256800,
"director": "Charlie Chaplin",
"directorURL": "https://www.imdb.com/name/nm0000122/"
}
]
},
"meta": {
"propertyDescriptors": [
{"id": "title", "name": "Title", "visible": true, "displayer": {"id": "link", "propertyHref": "url"}},
{"id": "genre", "name": "Genre", "visible": true},
{"id": "releaseDate", "name": "Release Date", "visible": true, "displayer": "date"},
{"id": "director", "name": "Director", "visible": true, "displayer": {"id": "link", "propertyHref": "directorURL"}}
]
}
}{{/liveData}}FAQ
Can a Live Data list entries from another wiki of the farm?
Working around XWIKI-22688, name the results page with its full reference, as in resultPage=xwiki:XWiki.LiveTableResults, and set the displayers by hand.
How do I check what a live table would look like as a Live Data?
Add useLiveData=true to the query string of the page holding it. Nothing is modified.
Why are the property names displayed as translation keys?
Because translationPrefix is missing, or does not match the keys declaring the property names.