Quantcast
Channel: XWiki Forum - Latest topics
Viewing all articles
Browse latest Browse all 1373

Best velocity practice querying page (class) property

$
0
0

Xwiki version: 16.3.1

Good afternoon everyone!

I think I have a pretty straightforward ‘challenge’ that I’ve spend too long trying to solve, I’m trying to retrieve a (class) property of another page.

I have the full adress of this other page: in the example case it’s : "Main.Werkwijze.Formulieren.Rapport van oplevering BMI"

When viewing the object of the page the class is listed as :

Main.Werkwijze.Formulieren.Code.FormulierenClass

when looking at the properties of the class object I can see the values I want to retrieve

So I’ve attempted the following so far (none return any value):

#set ($xdoc=$xwiki.getDocument($Formulier))
#set ($xobject = $xdoc.getObject('Main.Werkwijze.Formulieren.Code.FormulierenClass'))
#set ($xclass = $xobject.xWikiClass)
#foreach ($property in $xclass.properties)
  $property.Name
  $property.value
#end
#set ($xdoc=$xwiki.getDocument($Formulier))
$xdoc.display('Versienummer')
$xdoc.getValue('Versienummer')

I’ve also attempted variations of the class reference #set ($xobject = $xdoc.getObject('Main.Werkwijze.Formulieren.Code.FormulierenClass')) as it seems the $xobject variable remains empty.

Now I know from the documentation that there are $service queries that can be run on all the objects of a class aswell, and Im fairly confident that I can get my solution through that route… but I find myself wondering what the best practice is here… and perhaps a hint as to where I’m going wrong.

Thank you in advance for any and all feedback!

Greetings from the NL!

7 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 1373

Trending Articles