Accessing any class properties with liveData Macro

I’m still struggling to understand how to make the right questions to catch up with how XWiki works to access any piece of information and need some help.

If I’m able to access any property of XWikiUsers class with this very simple code:

{{liveData
  id="userbasics"
  properties="avatar,email,usertype,first_name"
  source="liveTable"
  sourceParameters="className=XWiki.XWikiUsers"
/}}

Why am I failing to get any result with this other very simple snippet?

{{liveData
  id="mailbasics"
  properties="subject,language"
  source="liveTable"
  sourceParameters="className=XWiki.Mail"
/}}

I’m sure our XWiki installation has several pages holding one or more instances of class XWiki.Mail. I’m afraid I’m failing to understand what source=“liveTable” does mean. Any help is greatly appreciated!

Thanks!

Hello @Ricardo_Rodriguez,

Some context to help you understand what’s going on.

Live Data is a generic front-end to display data in different layout. Table by default, but a Card view is also available.
To be able to get data to display in a Live Data, a source must be queried.
One of the main source we support is the liveTable one which works as a bridge to the Livetable source. This is really helpful as it allow to access all the sources already defined during the years where Livetable was the supported front-end to display data (i.e., a lot of sources).

But, you can define your own source in Java if you wish (we are lacking good documentation on this part but I’m working on it).

Then, the liveTable source can be provided with source parameters. The one you correctly used is the className, pointing the class you wish to list on your Live Table.
But, to ease things up and prevent duplication of the main values, we also provide implicit default configurations.
In your case, the queryFilters is set by default to currentlanguage,hidden. Meaning that the values are translated in the current local of the user, and hidden pages are displayed only when the user configuration allows them to be visible.
In my understanding, the user you tested with is not displaying hidden pages. And, all pages containing XWiki.Mail XObjects are hidden. Hence the empty Live Data.

So two options there:

  1. you’d like to keep this behavior. In this case you simply have to allow the view of hidden pages on the user’s properties
  2. you’d like to display the entries regardless of the user’s configuration, in this case you can override the default configuration on the source parameters of your user (see the snippet below).
{{liveData
  id="mailbasics"
  properties="subject,language"
  source="liveTable"
  sourceParameters="className=XWiki.Mail&queryFilters=currentlanguage"
/}}
1 Like

Thanks Manuel for the info! It could be good to improve the existing documentation (see https://dev.xwiki.org/xwiki/bin/view/Community/Contributing#HStrategiesforansweringquestions ;)) as this seems generic and could help others.

1 Like

were evil here! I will read several times your message and think a bit to find where I was lost and I would like to have found a reference to that detail!

I think the missing doc should be located around here https://extensions.xwiki.org/xwiki/bin/view/Extension/Live%20Data%20Macro/#HParameters-1
Finishing something and I’ll update it.

I’m still trying to understand the whole thing. Looking for queryFilters I found this release notes for XWiki 6.0. By entering an empty string as a value for queryFilters I can retrieve properties of all objects even although they are instantiated in hidden pages and my user’s display hidden pages remains NO as default. But what I’m not able to get is that properties in their languages. I have this:

image

And get this:

With the snippet:

{{liveData
  id="mailbasics"
  properties="subject,language"
  source="liveTable"
  sourceParameters="className=XWiki.Mail&queryFilters="
/}}

Where am I lost, please? Thanks!

In my understanding, this is the expected result. The subject property contains a velocity template used to generate the email subject (see here).
Can you tell us what you’re trying to do? It might help us provide a better answer.

I’m trying to understand how does liveData macro work! That is all so far!

It happens that I ended playing with XWiki class Mail. By using XWikiClasses, I get that there are six pages (Pages Count shows 6) holding Mail class objects instances;

Although there are actually only four different pages, one of them holding three instances of the Mail class:

I see that all properties of object XWiki.Mail are localized. Thus, they content strings translated to en, fr, and de:

image

What I think I understand now thanks to your explanation is that I get the content of the Subject property in the language of the page where the object is instantiated. As XWiki.SharePage has no locale, I get the Subject in the default language of my XWiki installation, English.

Am I correct?

One more thing. Why do I get Page Count = 6? Six is the total number of instances, but they are held by only 4 pages.

Thanks!

As the subject is just a plain string, it won’t be localized.

Looks like a bug, can you report it on jira.xwiki.org ? I’ll try to have a look. Thanks

I’m still lost with this. SharePage has three instances of XWiki.Mail. Each of them has a different Subject with part of the string in the language in the Language property. I see this, the same as in previous entry above:

image

As I’m querying XWiki for objects, I would expect to get the properties of every object. And I think I’m not getting that! I’ve added doc.title to be clearer with what I get:

I will report ASAP! I see jira.xwiki.org changed a lot since my last visit! I will catch up, create a new issue, and confirm its creation here.

Thanks!

Done! Loading... Thanks!

1 Like

Thanks for reporting, the issue is now fixed and will be available on all future releases.

1 Like