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: {{velocity}} ## 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()) #end {{/velocity}} 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 http://localhost:8080/xwiki/bin/view/XWiki/XWikiUsers and you can cnage it in the class editor: http://localhost:8080/xwiki/bin/edit/XWiki/XWikiUsers?editor=class but this document is in itself a user: the object eduitor is emprty: http://localhost:8080/xwiki/bin/edit/XWiki/XWikiUsers?editor=object (not completely empty, but does not contain XWiki.XWikiUsers objects) - the "admin" User document is not a class: http://localhost:8080/xwiki/bin/edit/XWiki/Admin?editor=class but has a Users oject attached: http://localhost:8080/xwiki/bin/edit/XWiki/Admin?editor=object 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 ...) {{velocity}} #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()) #end #end {{/velocity}} hth, clemens _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users