Wiki source code of Live Data Sources
Last modified by superadmin on 2026/11/25 21:42
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
![]() |
1.1 | 1 | 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>>doc:extensions:Extension.Component Module]] hint, and ##sourceParameters## carries the query string that source understands. |
| 2 | |||
| 3 | |=Source|=Hint|=Entries come from | ||
| 4 | |Live Table results|##liveTable##|Any [[live table>>doc:extensions:Extension.Livetable Macro]] results page, which makes an existing live table usable as a Live Data | ||
| 5 | |In-line data|N/A|The Macro content itself, written as JSON | ||
| 6 | |||
| 7 | Implementing a new source is described in [[Live Data Extension Points>>doc:documentation.xs.dev.livedata.extension-points.WebHome]]. | ||
| 8 | |||
| 9 | == Live Table Source == | ||
| 10 | |||
| 11 | 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. | ||
| 12 | |||
| 13 | It accepts these [[live table parameters>>doc:extensions:Extension.Livetable Macro||anchor="HParameter24options"]]: | ||
| 14 | |||
| 15 | |=Name|=Default Value|=Description | ||
| 16 | |##className##|N/A|The class whose objects are listed. Its properties become the properties of the entries. | ||
| 17 | |##resultPage##|##XWiki.LiveTableResults##|The page producing the results. | ||
| 18 | |##queryFilters##|##currentlanguage,hidden##|The [[query filters>>doc:extensions:Extension.Query Module]] 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". | ||
| 19 | |##translationPrefix##|N/A|The prefix of the translation keys used for the property names. | ||
| 20 | |##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. | ||
| 21 | |##hasEditMode##|##false##|{{version since="18.7.0RC1"}}Whether the reader may switch the Live Data to [[Edit mode>>doc:documentation.xs.user.livedata.edit-mode.WebHome]].{{/version}} | ||
| 22 | |##newRowLocation##|N/A|{{version since="18.7.0RC1"}}Location to store pages when creating new rows. Requires a compatible row naming strategy, //e.g.//, ##uuid##.{{/version}} | ||
![]() |
4.1 | 23 | |##newRowNamingStrategy##|N/A|{{version since="18.7.0RC1"}}How the pages of new rows are named, among the [[Row Naming Strategies>>||anchor="HRowNamingStrategies"]]. Rows can be added only when it is set and ##hasEditMode## is ##true##.{{/version}} |
| 24 | |##newRowTemplateProvider##|The template provider named after ##className##, as AppWithinMinutes names them: ##Space.BookTemplateProvider## for ##Space.BookClass##|{{version since="18.10.0RC1"}}The [[template provider>>doc:documentation.xs.admin.page-templates.WebHome]] whose template new rows start from, whatever the strategy: the values given in the row are applied on top of the template. ##XWiki.NoTemplateProvider## creates new rows without a template. A template provider or a template the reader cannot view is ignored.{{/version}} | ||
![]() |
1.1 | 25 | |
| 26 | 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>>doc:documentation.xs.user.livedata.migrate-live-table.WebHome]] says what to do with it. A live table that built its parameters in Velocity, as in: | ||
| 27 | |||
| 28 | {{code language="none"}} | ||
| 29 | {{velocity}} | ||
| 30 | #set ($options = { | ||
| 31 | 'className': 'ExtensionCode.ExtensionVersionClass', | ||
| 32 | 'location': "${doc.space}" | ||
| 33 | }) | ||
| 34 | |||
| 35 | {{liveData | ||
| 36 | id="versions" | ||
| 37 | properties="version,notes" | ||
| 38 | source="liveTable" | ||
| 39 | sourceParameters="$services.rendering.escape($escapetool.url($options), 'xwiki/2.1')" | ||
| 40 | /}} | ||
| 41 | {{/velocity}} | ||
| 42 | {{/code}} | ||
| 43 | |||
| 44 | passes them to the source the same way, once URL-encoded and escaped for the wiki syntax. | ||
| 45 | |||
![]() |
4.1 | 46 | === Row Naming Strategies === |
| 47 | |||
| 48 | {{version since="18.7.0RC1"}} | ||
| 49 | The ##newRowNamingStrategy## parameter takes one of these values, or the hint of a [[custom strategy>>doc:documentation.xs.dev.livedata.extension-points.WebHome||anchor="HNamingthePagesCreatedforNewEntries"]]: | ||
| 50 | |||
| 51 | |=Value|=Page name|=Location | ||
| 52 | |##uuid##|A random UUID|##newRowLocation## | ||
| 53 | |##title##|{{version since="18.10.0RC1"}}The title given in the new row, transformed by the [[name strategy>>doc:extensions:Extension.Model.Validation.UI.WebHome]] of the wiki when it transforms names. When a page with that name exists, the first free suffix among ##-1##, ##-2##, and so on, is appended.{{/version}}|##newRowLocation## | ||
| 54 | |##templateProvider##|{{version since="18.10.0RC1"}}Like ##title##, as a terminal or nested page following the "Terminal Page" field of the [[template provider>>doc:documentation.xs.admin.page-templates.template-provider-fields.WebHome]].{{/version}}|The first of the template provider's "Creation Restrictions". Without one, ##newRowLocation##. | ||
| 55 | |||
| 56 | {{version since="18.10.0RC1"}} | ||
| 57 | With ##title## and ##templateProvider##, the Live Data must display the ##doc.title## property, which [[Edit mode>>doc:documentation.xs.user.livedata.edit-mode.WebHome]] marks "(Required)". | ||
| 58 | {{/version}} | ||
| 59 | {{/version}} | ||
| 60 | |||
![]() |
1.1 | 61 | === Properties from Other Classes === |
| 62 | |||
| 63 | {{version since="18.0.0RC1"}} | ||
| 64 | 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. | ||
| 65 | |||
| 66 | {{code language="none"}} | ||
| 67 | {{liveData properties="doc.location,doc.title,tags" source="liveTable" sourceParameters="tags_class=XWiki.TagClass&translationPrefix=platform.index."/}} | ||
| 68 | {{/code}} | ||
| 69 | {{/version}} | ||
| 70 | |||
| 71 | == In-line Data == | ||
| 72 | |||
| 73 | 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. | ||
| 74 | |||
| 75 | {{code language="none"}} | ||
| 76 | {{liveData | ||
| 77 | id="movies" | ||
| 78 | properties="title,genre,releaseDate,director" | ||
| 79 | }}{ | ||
| 80 | "data": { | ||
| 81 | "count": 2, | ||
| 82 | "entries": [ | ||
| 83 | { | ||
| 84 | "title": "Meet John Doe", | ||
| 85 | "url": "https://www.imdb.com/title/tt0033891/", | ||
| 86 | "genre": ["Comedy", "Romance"], | ||
| 87 | "releaseDate": -904615200, | ||
| 88 | "director": "Frank Capra", | ||
| 89 | "directorURL": "https://www.imdb.com/name/nm0001008/" | ||
| 90 | }, | ||
| 91 | { | ||
| 92 | "title": "Modern Times", | ||
| 93 | "url": "https://www.imdb.com/title/tt0027977/", | ||
| 94 | "genre": ["Comedy", "Drama"], | ||
| 95 | "releaseDate": -1068256800, | ||
| 96 | "director": "Charlie Chaplin", | ||
| 97 | "directorURL": "https://www.imdb.com/name/nm0000122/" | ||
| 98 | } | ||
| 99 | ] | ||
| 100 | }, | ||
| 101 | "meta": { | ||
| 102 | "propertyDescriptors": [ | ||
| 103 | {"id": "title", "name": "Title", "visible": true, "displayer": {"id": "link", "propertyHref": "url"}}, | ||
| 104 | {"id": "genre", "name": "Genre", "visible": true}, | ||
| 105 | {"id": "releaseDate", "name": "Release Date", "visible": true, "displayer": "date"}, | ||
| 106 | {"id": "director", "name": "Director", "visible": true, "displayer": {"id": "link", "propertyHref": "directorURL"}} | ||
| 107 | ] | ||
| 108 | } | ||
| 109 | }{{/liveData}} | ||
| 110 | {{/code}} | ||
| 111 | |||
| 112 | {{warning}} | ||
| 113 | Please note that In-Line Data [[currently does not support filtering, sorting, or pagination>>https://jira.xwiki.org/browse/XWIKI-19783]]. Therefore, it is recommended to deactivate these features to avoid unexpected error messages when the table Topbar and the Bottombar is used. While filtering and sorting are disabled by default if not set, pagination must be explicitly disabled in the "meta" section of the JSON configuration: | ||
| 114 | |||
| 115 | {{code language="none"}} | ||
| 116 | "pagination": { | ||
| 117 | "showEntryRange": false, | ||
| 118 | "showNextPrevious": false, | ||
| 119 | "showFirstLast": false | ||
| 120 | } | ||
| 121 | {{/code}} | ||
| 122 | |||
![]() |
2.1 | 123 | If you want to avoid also displaying the remaining and buggy Page Counter or hide the entire Topbar/Bottombar without disabling pagination in the JSON configuration, you can achieve this using a XWiki.StyleSheetExtension for that specific page, as documented in the [[Skin Extension Tutorial>>xwiki:documentation.xs.dev.skin-extensions.WebHome]]: |
![]() |
4.1 | 124 | {{code language="css"}}.livedata-topbar {display: none !important;} |
| 125 | .livedata-bottombar {display: none !important;}{{/code}} | ||
![]() |
1.1 | 126 | {{/warning}} |

