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@67775d74

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@54c36bd6, com.xpn.xwiki.api.Object@69dcda13, com.xpn.xwiki.api.Object@22714bb1, com.xpn.xwiki.api.Object@3c206321, com.xpn.xwiki.api.Object@724c2a5d, com.xpn.xwiki.api.Object@66717a4a, com.xpn.xwiki.api.Object@2413c4d1, com.xpn.xwiki.api.Object@dde87d8, com.xpn.xwiki.api.Object@ca87d05]

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