Toggle navigation
Log-in
Languages
English
Wiki Index
Page Index
User Index
ICT
Groovy
Wiki source code of
Groovy
Last modified by
Ricardo Rodríguez Fernández
on 2017/02/27 11:03
Hide line numbers
1: **Retrieve the first object (index [0]) among all objects attached to this page and class XWikiComments** 2: 3: {{code language="groovy"}} 4: obj = doc.getObject('XWiki.XWikiComments') 5: {{/code}} 6: 7: {{groovy}} 8: obj = doc.getObject('XWiki.XWikiComments') 9: println obj 10: {{/groovy}} 11: 12: 13: 14: **Retrieve all objects attached to this page and of class XWikiComments** 15: 16: {{code language="groovy"}} 17: objs = doc.getObjects('XWiki.XWikiComments') 18: {{/code}} 19: 20: {{groovy}} 21: objs = doc.getObjects('XWiki.XWikiComments') 22: println objs 23: {{/groovy}} 24: 25: 26: 27: **Retrieve the author property of all objects attached to this page and of class XWikiComments** 28: 29: {{code language="groovy"}} 30: objsAuthors = doc.getObjects('XWiki.XWikiComments').author 31: println objsAuthors 32: {{/code}} 33: 34: {{groovy}} 35: objsAuthors = doc.getObjects('XWiki.XWikiComments').author 36: println objsAuthors 37: {{/groovy}} 38: 39: 40: 41: **Retrieve the author property of the fifth object attached to this page and of class XWikiComments by index** 42: 43: {{code language="groovy"}} 44: objsAuthor = doc.getObjects('XWiki.XWikiComments')[4].author 45: println objsAuthor 46: {{/code}} 47: 48: {{groovy}} 49: objsAuthor = doc.getObjects('XWiki.XWikiComments')[4].author 50: println objsAuthor 51: {{/groovy}} 52: 53: 54: 55: **Retrieve the author property of the first object attached to this page and of class XWikiComments by index; objs was assigned above!** 56: 57: {{code language="groovy"}} 58: println objs[0].author 59: {{/code}} 60: 61: {{groovy}} 62: println objs[0].author 63: {{/groovy}}