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@1c6d0cce

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@74a3a40e, com.xpn.xwiki.api.Object@2367cef5, com.xpn.xwiki.api.Object@744448fb, com.xpn.xwiki.api.Object@2f13925f, com.xpn.xwiki.api.Object@2deeb31e, com.xpn.xwiki.api.Object@12318e21, com.xpn.xwiki.api.Object@736a21db, com.xpn.xwiki.api.Object@3cd4ec0f, com.xpn.xwiki.api.Object@3ed5ebfc]

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