[xwiki-users] command to delete a comment
Hello In a groovy macro I can access the comments on the page like this : comments = doc.getComments(); now I want to delete the last one... how can I do that? I tried : comments[0].delete(); but it doesn't work.... do you know what to type to make it work? Thanks a lot Adrien
On 27 Nov 2014 at 14:37:50, Adrien Moi ([email protected](mailto:[email protected])) wrote:
Hello
In a groovy macro I can access the comments on the page like this :
comments = doc.getComments();
now I want to delete the last one... how can I do that?
I tried : comments[0].delete(); but it doesn't work....
do you know what to type to make it work?
You can get the xobjects of type XWiki.XWikiComments and remove the last one. Check $doc in the SRD. Something like $doc.getObjects(“XWiki.XWikiComments”) and then $doc.removeObject(objct). And don’t forget to save the doc in the end: $doc.save(…). Would be interesting to have a code snippet on extensions.xwiki.org showing this… Thanks -Vincent
Thanks a lot Adrien
On 27 Nov 2014 at 14:51:40, [email protected] ([email protected](mailto:[email protected])) wrote:
On 27 Nov 2014 at 14:37:50, Adrien Moi ([email protected](mailto:[email protected])) wrote:
Hello
In a groovy macro I can access the comments on the page like this :
comments = doc.getComments();
now I want to delete the last one... how can I do that?
I tried : comments[0].delete(); but it doesn't work....
do you know what to type to make it work?
You can get the xobjects of type XWiki.XWikiComments and remove the last one.
Check $doc in the SRD. Something like $doc.getObjects(“XWiki.XWikiComments”) and then $doc.removeObject(objct).
And don’t forget to save the doc in the end: $doc.save(…).
Would be interesting to have a code snippet on extensions.xwiki.org(http://extensions.xwiki.org) showing this…
You can also check these examples: http://extensions.xwiki.org/xwiki/bin/view/Main/Tags?do=viewTag&tag=comments Thanks -Vincent
Thanks -Vincent
Thanks a lot Adrien
participants (2)
-
Adrien Moi -
vincent@massol.net