[xwiki-users] New Notifications Tutorial (a.k.a Event Listener)
Dear XWiki users, Since I’ve seen several questions recently on the list related to XWiki events, I’ve spent several hours rewriting the XWiki Notifications Tutorial here: http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingEventListenerTutori... You’ll learn for example: - Adding content to pages on save - Log when a document is modified - Send a mail whenever a comment is added Enjoy! Thanks -Vincent
Event listeners should not keep a reference to the XWiki context from when they were created. XWiki context is created per request while the event listener is used on multiple requests. I updated the LoggingEventListener. Thanks, Marius On Thu, May 29, 2014 at 7:39 PM, [email protected] <[email protected]> wrote:
Dear XWiki users,
Since I’ve seen several questions recently on the list related to XWiki events, I’ve spent several hours rewriting the XWiki Notifications Tutorial here:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingEventListenerTutori...
You’ll learn for example: - Adding content to pages on save - Log when a document is modified - Send a mail whenever a comment is added
Enjoy!
Thanks -Vincent
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
On 30 May 2014 at 07:39:44, Marius Dumitru Florea ([email protected](mailto:[email protected])) wrote:
Event listeners should not keep a reference to the XWiki context from when they were created. XWiki context is created per request while the event listener is used on multiple requests. I updated the LoggingEventListener.
Thanks but I think it’s better to get it from the passed “data” parameters which represents the XWikiContext. Also http://platform.xwiki.org/xwiki/bin/download/DevGuide/WritingEventListenerTu... needs to be updated too. Thanks -Vincent
Thanks, Marius
On Thu, May 29, 2014 at 7:39 PM, [email protected] wrote:
Dear XWiki users,
Since I’ve seen several questions recently on the list related to XWiki events, I’ve spent several hours rewriting the XWiki Notifications Tutorial here:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingEventListenerTutori...
You’ll learn for example: - Adding content to pages on save - Log when a document is modified - Send a mail whenever a comment is added
Enjoy!
Thanks -Vincent
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
On Fri, May 30, 2014 at 9:32 AM, [email protected] <[email protected]> wrote:
On 30 May 2014 at 07:39:44, Marius Dumitru Florea ([email protected](mailto:[email protected])) wrote:
Event listeners should not keep a reference to the XWiki context from when they were created. XWiki context is created per request while the event listener is used on multiple requests. I updated the LoggingEventListener.
Thanks but I think it’s better to get it from the passed “data” parameters which represents the XWikiContext.
I didn't say otherwise :) , even if you get it from the passed "data" or from the execution context you should still not keep a reference to the XWiki context between events.
Also http://platform.xwiki.org/xwiki/bin/download/DevGuide/WritingEventListenerTu... needs to be updated too.
Thanks -Vincent
Thanks, Marius
On Thu, May 29, 2014 at 7:39 PM, [email protected] wrote:
Dear XWiki users,
Since I’ve seen several questions recently on the list related to XWiki events, I’ve spent several hours rewriting the XWiki Notifications Tutorial here:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingEventListenerTutori...
You’ll learn for example: - Adding content to pages on save - Log when a document is modified - Send a mail whenever a comment is added
Enjoy!
Thanks -Vincent
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
I am trying to use the maven to mount the Listener component, however I am getting this following error:
mvn clean install
[ERROR] Failed to execute goal on project commentListener: Could not resolve dep endencies for project com.energisa:commentListener:jar:1.0-SNAPSHOT: The followi ng artifacts could not be resolved: org.xwiki.platform:xwiki-platform-oldcore:ja r:5.4.4, org.xwiki.platform:xwiki-platform-mailsender:jar:5.4.4: Could not find artifact org.xwiki.platform:xwiki-platform-oldcore:jar:5.4.4 in central (http:// repo.maven.apache.org/maven2) -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit ch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please rea d the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyReso lutionException Do I need to configure the repositories in Maven, in order to make it download from the right place? Thank you. Danilo Grupo Energisa Danilo Oliveira Analista Suporte Aplicacao TI - DPTO CORP. DE INFRAESTR. TI e-mail: [email protected] | tel: (32) 3429-6342 | cel: (32) 8452-9478 Esta mensagem contém informação confidencial. Se você a recebeu por engano, não divulgue ou copie seu conteúdo. Por favor, avise ao remetente imediatamente e apague-a do computador. Privileged and confidential. If this message has been received by mistake, do not disclose or copy its contents. Please notify sender and delete immediately. -----Mensagem original----- De: users [mailto:[email protected]] Em nome de Marius Dumitru Florea Enviada em: sexta-feira, 30 de maio de 2014 04:32 Para: XWiki Users Assunto: Re: [xwiki-users] New Notifications Tutorial (a.k.a Event Listener) On Fri, May 30, 2014 at 9:32 AM, [email protected] <[email protected]> wrote:
On 30 May 2014 at 07:39:44, Marius Dumitru Florea ([email protected](mailto:[email protected])) wrote:
Event listeners should not keep a reference to the XWiki context from when they were created. XWiki context is created per request while the event listener is used on multiple requests. I updated the LoggingEventListener.
Thanks but I think it’s better to get it from the passed “data” parameters which represents the XWikiContext.
I didn't say otherwise :) , even if you get it from the passed "data" or from the execution context you should still not keep a reference to the XWiki context between events.
Also http://platform.xwiki.org/xwiki/bin/download/DevGuide/WritingEventListenerTu... needs to be updated too.
Thanks -Vincent
Thanks, Marius
On Thu, May 29, 2014 at 7:39 PM, [email protected] wrote:
Dear XWiki users,
Since I’ve seen several questions recently on the list related to XWiki events, I’ve spent several hours rewriting the XWiki Notifications Tutorial here:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingEventListe nerTutorial
You’ll learn for example: - Adding content to pages on save - Log when a document is modified - Send a mail whenever a comment is added
Enjoy!
Thanks -Vincent
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Hi, Yes, see here: http://dev.xwiki.org/xwiki/bin/view/Community/Building Br, Jérémie Le 30 mai 2014 16:22, "Danilo Amaral de Oliveira" < [email protected]> a écrit :
I am trying to use the maven to mount the Listener component, however I am getting this following error:
mvn clean install
[ERROR] Failed to execute goal on project commentListener: Could not resolve dep endencies for project com.energisa:commentListener:jar:1.0-SNAPSHOT: The followi ng artifacts could not be resolved: org.xwiki.platform:xwiki-platform-oldcore:ja r:5.4.4, org.xwiki.platform:xwiki-platform-mailsender:jar:5.4.4: Could not find artifact org.xwiki.platform:xwiki-platform-oldcore:jar:5.4.4 in central (http:// repo.maven.apache.org/maven2) -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit ch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please rea d the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyReso lutionException
Do I need to configure the repositories in Maven, in order to make it download from the right place?
Thank you. Danilo
Grupo Energisa Danilo Oliveira Analista Suporte Aplicacao TI - DPTO CORP. DE INFRAESTR. TI e-mail: [email protected] | tel: (32) 3429-6342 | cel: (32) 8452-9478
Esta mensagem contém informação confidencial. Se você a recebeu por engano, não divulgue ou copie seu conteúdo. Por favor, avise ao remetente imediatamente e apague-a do computador. Privileged and confidential. If this message has been received by mistake, do not disclose or copy its contents. Please notify sender and delete immediately.
-----Mensagem original----- De: users [mailto:[email protected]] Em nome de Marius Dumitru Florea Enviada em: sexta-feira, 30 de maio de 2014 04:32 Para: XWiki Users Assunto: Re: [xwiki-users] New Notifications Tutorial (a.k.a Event Listener)
On Fri, May 30, 2014 at 9:32 AM, [email protected] <[email protected]> wrote:
On 30 May 2014 at 07:39:44, Marius Dumitru Florea (
[email protected](mailto:[email protected])) wrote:
Event listeners should not keep a reference to the XWiki context from when they were created. XWiki context is created per request while the event listener is used on multiple requests. I updated the LoggingEventListener.
Thanks but I think it’s better to get it from the passed “data” parameters which represents the XWikiContext.
I didn't say otherwise :) , even if you get it from the passed "data" or from the execution context you should still not keep a reference to the XWiki context between events.
Also
http://platform.xwiki.org/xwiki/bin/download/DevGuide/WritingEventListenerTu... needs to be updated too.
Thanks -Vincent
Thanks, Marius
On Thu, May 29, 2014 at 7:39 PM, [email protected] wrote:
Dear XWiki users,
Since I’ve seen several questions recently on the list related to
XWiki events, I’ve spent several hours rewriting the XWiki Notifications Tutorial here:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingEventListe nerTutorial
You’ll learn for example: - Adding content to pages on save - Log when a document is modified - Send a mail whenever a comment is added
Enjoy!
Thanks -Vincent
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Hello Vincent and all, I've been successfully making my first (java-based) component (I can call it from other places) using hints from there and the components' tutorial. However, I have failed to get that component to listen to events. While another, groovy-based, listener is notified, my onEvent is not called. getEvents is returning objects that I would desire public List<Event> getEvents() { return Arrays.<Event>asList( new AttachmentUpdatedEvent(), new AttachmentDeletedEvent()); } (I would prefer an abstract type used here, but I need concrete objects) What else can wrong in my listener? Shouldn't there be listener registration at components? (e.g. in the initialize method) thanks paul On 29 mai 2014, at 18:39, [email protected] wrote:
Dear XWiki users,
Since I’ve seen several questions recently on the list related to XWiki events, I’ve spent several hours rewriting the XWiki Notifications Tutorial here:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingEventListenerTutori...
You’ll learn for example: - Adding content to pages on save - Log when a document is modified - Send a mail whenever a comment is added
On 06/13/2014 01:18 AM, Paul Libbrecht wrote:
Hello Vincent and all,
I've been successfully making my first (java-based) component (I can call it from other places) using hints from there and the components' tutorial.
However, I have failed to get that component to listen to events. While another, groovy-based, listener is notified, my onEvent is not called.
getEvents is returning objects that I would desire public List<Event> getEvents() { return Arrays.<Event>asList( new AttachmentUpdatedEvent(), new AttachmentDeletedEvent()); }
(I would prefer an abstract type used here, but I need concrete objects)
What else can wrong in my listener? Shouldn't there be listener registration at components? (e.g. in the initialize method)
yes, for registration you need to add the class to the META-INF/components.txt like explained somewhere: http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HCompo... (and in the Notifications Tutorial, too, I now see after careful reading ...) some things to try if it still does not work: - check if there are no error messages in the log file on startup - maybe try "extend AbstractEventListener" instead of "implement EventListener" (that should *not* fix any problems, but maybe it gives an explicit error message instead of failing) clemens
Hello XWiki experts,
What else can wrong in my listener? Shouldn't there be listener registration at components? (e.g. in the initialize method) yes, for registration you need to add the class to the META-INF/components.txt
Sure, that's done, couldn't get Utils.getComponent to work otherwise.
like explained somewhere: http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HCompo... (and in the Notifications Tutorial, too, I now see after careful reading ...)
some things to try if it still does not work: - check if there are no error messages in the log file on startup - maybe try "extend AbstractEventListener" instead of "implement EventListener" (that should *not* fix any problems, but maybe it gives an explicit error message instead of failing)
I just recopied the CommentEventListener which listens to changed comments, and that worked. So I suspected by use of AttachmentDeletedEvent and AttachmentUpdatedEvent was wrong and I added DocumentUpdatedEvent as one of the types I was interested in. I am nicely receiving them. However, how can I know if the difference is in an attachment? RCS? thanks in advance. Paul
On Sat, Jun 14, 2014 at 12:01 AM, Paul Libbrecht <[email protected]> wrote:
Hello XWiki experts,
What else can wrong in my listener? Shouldn't there be listener registration at components? (e.g. in the initialize method) yes, for registration you need to add the class to the META-INF/components.txt
Sure, that's done, couldn't get Utils.getComponent to work otherwise.
like explained somewhere: http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HCompo... (and in the Notifications Tutorial, too, I now see after careful reading ...)
some things to try if it still does not work: - check if there are no error messages in the log file on startup - maybe try "extend AbstractEventListener" instead of "implement EventListener" (that should *not* fix any problems, but maybe it gives an explicit error message instead of failing)
I just recopied the CommentEventListener which listens to changed comments, and that worked. So I suspected by use of AttachmentDeletedEvent and AttachmentUpdatedEvent was wrong and I added DocumentUpdatedEvent as one of the types I was interested in. I am nicely receiving them.
You did not listen to AttachmentAddedEvent ? AttachmentUpdatedEvent only refers to already existing attachment updated with a new version.
However, how can I know if the difference is in an attachment? RCS?
thanks in advance.
Paul _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
I just recopied the CommentEventListener which listens to changed comments, and that worked. So I suspected by use of AttachmentDeletedEvent and AttachmentUpdatedEvent was wrong and I added DocumentUpdatedEvent as one of the types I was interested in. I am nicely receiving them.
You did not listen to AttachmentAddedEvent ? AttachmentUpdatedEvent only refers to already existing attachment updated with a new version.
However, how can I know if the difference is in an attachment? RCS?
Thanks Thomas, now I did listen to the AttachmentAddedEvent and it is indeed fired. However… I do not see a way, from this event, to actually know which attachment was changed. Is this not recorded? In my only experience about notifications, I had to diff quite many things and it does not seem like it's a good or necessary idea. thanks in advance. Paul
On Tue, Jun 17, 2014 at 10:25 AM, Paul Libbrecht <[email protected]> wrote:
I just recopied the CommentEventListener which listens to changed comments, and that worked. So I suspected by use of AttachmentDeletedEvent and AttachmentUpdatedEvent was wrong and I added DocumentUpdatedEvent as one of the types I was interested in. I am nicely receiving them.
You did not listen to AttachmentAddedEvent ? AttachmentUpdatedEvent only refers to already existing attachment updated with a new version.
However, how can I know if the difference is in an attachment? RCS?
Thanks Thomas,
now I did listen to the AttachmentAddedEvent and it is indeed fired. However… I do not see a way, from this event, to actually know which attachment was changed. Is this not recorded?
Should be AttachmentAddedEvent#getName() (actually AbstractDocumentEvent#getName())
In my only experience about notifications, I had to diff quite many things and it does not seem like it's a good or necessary idea.
thanks in advance.
Paul _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
On Tue, Jun 17, 2014 at 11:05 AM, Thomas Mortagne <[email protected]> wrote:
On Tue, Jun 17, 2014 at 10:25 AM, Paul Libbrecht <[email protected]> wrote:
I just recopied the CommentEventListener which listens to changed comments, and that worked. So I suspected by use of AttachmentDeletedEvent and AttachmentUpdatedEvent was wrong and I added DocumentUpdatedEvent as one of the types I was interested in. I am nicely receiving them.
You did not listen to AttachmentAddedEvent ? AttachmentUpdatedEvent only refers to already existing attachment updated with a new version.
However, how can I know if the difference is in an attachment? RCS?
Thanks Thomas,
now I did listen to the AttachmentAddedEvent and it is indeed fired. However… I do not see a way, from this event, to actually know which attachment was changed. Is this not recorded?
Should be AttachmentAddedEvent#getName() (actually AbstractDocumentEvent#getName())
The first parameter passed with the event (source) is the new XWikiDocument instance.
In my only experience about notifications, I had to diff quite many things and it does not seem like it's a good or necessary idea.
thanks in advance.
Paul _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
-- Thomas Mortagne
participants (7)
-
Clemens Klein-Robbenhaar -
Danilo Amaral de Oliveira -
Jeremie BOUSQUET -
Marius Dumitru Florea -
Paul Libbrecht -
Thomas Mortagne -
vincent@massol.net