Groovy


Retrieve the first object (index [0]) among all objects attached to this page and of a certain class

obj = doc.getObject('XWiki.XWikiComments')

com.xpn.xwiki.api.Object@6c9ad6e

Retrieve all objects attached to this page and of a certain class and one of their properties

objs = doc.getObjects('XWiki.XWikiComments')

[com.xpn.xwiki.api.Object@dbbe992, com.xpn.xwiki.api.Object@2be37749, com.xpn.xwiki.api.Object@62ac7021, com.xpn.xwiki.api.Object@26f5b923, com.xpn.xwiki.api.Object@4e4dbcd0, com.xpn.xwiki.api.Object@51a723d9, com.xpn.xwiki.api.Object@3422a570, com.xpn.xwiki.api.Object@4e9b76cd, com.xpn.xwiki.api.Object@4094b50c]

objsAuthors = doc.getObjects('XWiki.XWikiComments').author
objsAuthor = doc.getObjects('XWiki.XWikiComments')[2].author
println objs[0].author
println objsAuthors
println objsAuthor

Tags:
Created by Ricardo Rodríguez Fernández on 2017/02/15 23:05
    
This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 7.3 - Documentation