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@66f237c7

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@3b74b181, com.xpn.xwiki.api.Object@6a31aaa5, com.xpn.xwiki.api.Object@62ba6d1a, com.xpn.xwiki.api.Object@3d50f899, com.xpn.xwiki.api.Object@ef12442, com.xpn.xwiki.api.Object@798370b7, com.xpn.xwiki.api.Object@245d3cb4, com.xpn.xwiki.api.Object@653c6012, com.xpn.xwiki.api.Object@5ec771aa]

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