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@2e810773

Retrieve all objects attached to this page and of class XWikiComments

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

[com.xpn.xwiki.api.Object@4669cac8, com.xpn.xwiki.api.Object@4b803495, com.xpn.xwiki.api.Object@4dfc48ec, com.xpn.xwiki.api.Object@6e17a5f3, com.xpn.xwiki.api.Object@52902cfc, com.xpn.xwiki.api.Object@77797ebc, com.xpn.xwiki.api.Object@496fa5eb, com.xpn.xwiki.api.Object@40f60cf7, com.xpn.xwiki.api.Object@59cd4d72, com.xpn.xwiki.api.Object@3597a56d]

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

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

[26/02/2017 08:50:18, 26/02/2017 08:50:26, 26/02/2017 08:50:33, 26/02/2017 08:50:43, 27/02/2017 08:19:40, 27/02/2017 08:20:00, 27/02/2017 08:20:54, 27/02/2017 10:22:23, 27/02/2017 10:23:01, 27/02/2017 10:58:47]

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

Retrieve the author property of the first object attached to this page and of class XWikiComments by index; objs was assigned above!

println objs[0].author

XWiki.RicardoRodriguezFernandez

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