On Sun, Oct 21, 2012 at 6:01 PM, Boudjelda Mohamed Said <[email protected]> wrote: > Hi Xwiki developers > > I would like to know what is the best way to get fields of a Class > created on Xwiki ? I tried with reflection but things seems not work right
The following code, taken from XWiki.ClassSheet ( https://github.com/xwiki/xwiki-enterprise/blob/master/xwiki-enterprise-ui/src/main/resources/XWiki/ClassSheet.xml#L125 ), lists all the fields of the Blog.BlogPostClass : ----------8<---------- {{velocity}} #set ($classDocument = $xwiki.getDocument('Blog.BlogPostClass')) #foreach($property in $classDocument.getxWikiClass().properties) * $property.prettyName ($property.name: $xwiki.metaclass.get($property.classType).prettyName) #end {{/velocity}} ---------->8---------- You cannot use Java reflection on an XWiki class (to get its fields) because it isn't a real Java class, i.e. the fields are not static Java class fields. You can however use $classDocument.getxWikiClass().class.name (in Velocity) to get the name of the Java class used to implement the XClass (in order to know the available API). Hope this helps, Marius > , I do not even know what class to use. please would you give me some key > notes on that subject. > > Thanks > _______________________________________________ > users mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/users _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
