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@332333dc

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@70ffbd78, com.xpn.xwiki.api.Object@25f04b3d, com.xpn.xwiki.api.Object@42dba540, com.xpn.xwiki.api.Object@623e2f0a, com.xpn.xwiki.api.Object@60826be9, com.xpn.xwiki.api.Object@127abf7f, com.xpn.xwiki.api.Object@38b23453, com.xpn.xwiki.api.Object@3b895239, com.xpn.xwiki.api.Object@34753ab8]

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