On 02/09/2015 02:12 PM, Pascal BASTIEN wrote:
> This code (probably false) doesn't work.
> #set( $Class = $xwiki.getClass("MySpace.MyClass"))
> #foreach($prop in $class.properties) ## go through all properties
>  * ${prop.prettyName} : $doc.display($prop.getName())
> #end

It works for me if I do something like:

## get the document which has the object (only one here) - this is the page 
where I can see things in the object editor
#set( $adminDoc = $xwiki.getDocument("XWiki.Admin"))
## get the document wich contains the class definition: this page has entries 
in the class editor
#set( $class = $xwiki.getClass("XWiki.XWikiUsers"))
#foreach($prop in $class.properties) ## go through all properties
 * ${prop.prettyName} : $adminDoc.display($prop.getName())

This code should work for you 1:1 unless you have deleted you "Admin" user. 
toapply for your ise case you will have to adapt the name of the class and of 
the document containing the objects

Note that there is a difference between:

 - the document _defining_ the class - for users this is XWiki.XWikiUsers and 
you can see it at
   and you can cnage it  in the class editor:
   but this document is in itself a user: the object eduitor is emprty:
   (not completely empty, but does not contain XWiki.XWikiUsers objects)

 - the "admin" User document is not a class:
   but has a Users oject attached:

Anyway, if you have more than one object on a page, you will have to loop over 
them and use "$doc.use".

the following works for me (even though it is useless in this case, as is loops 
over all users on a page, while there should be only one ...)

#set($adminDoc = $xwiki.getDocument("XWiki.Admin"))
#set($class = $xwiki.getClass("XWiki.XWikiUsers"))
## loop over all objects
#foreach($obj in $adminDoc.getObjects("XWiki.XWikiUsers"))
  ## empty line is intentionally to create a new paragraph

  Object number $velocityCount
  #set($discard = $adminDoc.use($obj))
  #foreach($prop in $class.properties) ## go through all properties
    * ${prop.prettyName} : $adminDoc.display($prop.getName())



users mailing list

Reply via email to