Groovy


Retrieve the first object (index [0]) among all objects attached to this page and class XWikiComments

obj = doc.getObject('XWiki.XWikiComments')

com.xpn.xwiki.api.Object@907b639

Retrieve all objects attached to this page and of class XWikiComments

objs = doc.getObjects('XWiki.XWikiComments')

[com.xpn.xwiki.api.Object@31f5f4ba, com.xpn.xwiki.api.Object@a95f8f6, com.xpn.xwiki.api.Object@7c0be3e7, com.xpn.xwiki.api.Object@709f9250, com.xpn.xwiki.api.Object@7c3efbf3, com.xpn.xwiki.api.Object@b0f4e3f, com.xpn.xwiki.api.Object@19da0fc5, com.xpn.xwiki.api.Object@3b415bc5, com.xpn.xwiki.api.Object@3ff000e7]

Retrieve the author property of all objects attached to this page and of class XWikiComments

objsAuthors = doc.getObjects('XWiki.XWikiComments').author
println objsAuthors

[XWiki.RicardoRodriguezFernandez, XWiki.RicardoRodriguezFernandez, XWiki.RicardoRodriguezFernandez, XWiki.RicardoRodriguezFernandez, XWiki.IsabelListaGarcia, Anonymous, XWiki.YolandaMariaListeMartinez, XWiki.RicardoRodriguezFernandez, XWiki.RicardoRodriguezFernandez]

Retrieve the author property of the fifth object attached to this page and of class XWikiComments by index

objsAuthor = doc.getObjects('XWiki.XWikiComments')[4].author
println objsAuthor

XWiki.IsabelListaGarcia

println objs[0].author

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