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@5bd5606b

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@42fef67a, com.xpn.xwiki.api.Object@70e7e5f2, com.xpn.xwiki.api.Object@8a9acc7, com.xpn.xwiki.api.Object@3b8e4142, com.xpn.xwiki.api.Object@785e7299, com.xpn.xwiki.api.Object@b5d88c, com.xpn.xwiki.api.Object@229bcfb1, com.xpn.xwiki.api.Object@23607f37, com.xpn.xwiki.api.Object@14400606]

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