[xwiki-users] Changing a document object during a notification
Hello, I'm using XWiki notification API ( http://platform.xwiki.org/xwiki/bin/view/DevGuide/Notifications) and now I need to change a property of the document that is being changed by the user. I tried simply changing the value but this does not persist it - after rebooting the server the value is not there anymore. Using the context.getWiki.saveDocument method was not a very bright idea either because it started an infinite recursion - it called my notification code back again. So, does anybody know what could I do? Thank you very much, -- Tiago Rinck Caveden http://caveden.multiply.com
Tiago Rinck Caveden wrote:
Hello,
I'm using XWiki notification API ( http://platform.xwiki.org/xwiki/bin/view/DevGuide/Notifications) and now I need to change a property of the document that is being changed by the user. I tried simply changing the value but this does not persist it - after rebooting the server the value is not there anymore. Using the context.getWiki.saveDocument method was not a very bright idea either because it started an infinite recursion - it called my notification code back again.
So, does anybody know what could I do?
Yes, use prenotifications. This means that instead of putting the code in verify(), put it in preverify(), and use the constructor with 3 arguments. -- Sergiu Dumitriu http://purl.org/net/sergiu/
Sergiu Dumitriu wrote:
Tiago Rinck Caveden wrote:
Hello,
I'm using XWiki notification API ( http://platform.xwiki.org/xwiki/bin/view/DevGuide/Notifications) and now I need to change a property of the document that is being changed by the user. I tried simply changing the value but this does not persist it - after rebooting the server the value is not there anymore. Using the context.getWiki.saveDocument method was not a very bright idea either because it started an infinite recursion - it called my notification code back again.
So, does anybody know what could I do?
Yes, use prenotifications. This means that instead of putting the code in verify(), put it in preverify(), and use the constructor with 3 arguments.
I hit Send to soon, and my notification knowledge is a bit rusty... I mean, when creating the notification rule (DocChangeRule or whichever you're using), use the constructor with 3 arguments, and use true for the second argument, false for the third one. If the Rule doesn't have such a constructor, call setPostverify(false) and setPreverify(true). That's all you need to do. -- Sergiu Dumitriu http://purl.org/net/sergiu/
On Wed, Jun 25, 2008 at 7:31 PM, Sergiu Dumitriu <[email protected]> wrote:
Sergiu Dumitriu wrote:
Yes, use prenotifications. This means that instead of putting the code in verify(), put it in preverify(), and use the constructor with 3 arguments.
I hit Send to soon, and my notification knowledge is a bit rusty...
I mean, when creating the notification rule (DocChangeRule or whichever you're using), use the constructor with 3 arguments, and use true for the second argument, false for the third one. If the Rule doesn't have such a constructor, call setPostverify(false) and setPreverify(true). That's all you need to do.
Thanks, that helped me! I have one more question... isn't the EVENT_UPDATE_OBJECT event code ever used? I only need to execute my code when the object in the page is changed, so I made an if with this event but then the code stopped being called. I made an Eclipse search over the variable and it didn't find any use all over XWiki's source code... []'s -- Tiago Rinck Caveden http://caveden.multiply.com
On Thu, Jun 26, 2008 at 11:39 AM, Tiago Rinck Caveden <[email protected]> wrote:
I have one more question... isn't the EVENT_UPDATE_OBJECT event code ever used? I only need to execute my code when the object in the page is changed, so I made an if with this event but then the code stopped being called. I made an Eclipse search over the variable and it didn't find any use all over XWiki's source code...
And now I'm trying to distinguish the behavior of an update from the one of a delete and I can't manage to... apparently the event == EVENT_DELETE is not being sent... Or may I be doing something wrong? Thanks, -- Tiago Rinck Caveden http://caveden.multiply.com
Maybe this http://tinyurl.com/3hzmjd can help. It's the ActivityStream implementation for Curriki. It uses the Notification System. Take a look.
On Thu, Jun 26, 2008 at 11:39 AM, Tiago Rinck Caveden <[email protected]> wrote:
I have one more question... isn't the EVENT_UPDATE_OBJECT event code ever used? I only need to execute my code when the object in the page is changed, so I made an if with this event but then the code stopped being called. I made an Eclipse search over the variable and it didn't find any use all over XWiki's source code...
And now I'm trying to distinguish the behavior of an update from the one of a delete and I can't manage to... apparently the event == EVENT_DELETE is not being sent...
Or may I be doing something wrong?
Thanks, -- Tiago Rinck Caveden http://caveden.multiply.com _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Hello! On Thu, Jun 26, 2008 at 2:29 PM, Marius Dumitru Florea < [email protected]> wrote:
Maybe this http://tinyurl.com/3hzmjd can help. It's the ActivityStream implementation for Curriki. It uses the Notification System. Take a look.
Thanks. I took a quick look, and I saw that the code there seems to be trying to guess which is the event by inspecting the objects and properties of the documents, is that right? If it is like that, why is the "event" int parameter there anyway? I thought it was his "job" to inform this.... if he always come with the same value it looks a bit weird. Anyway, I'm guessing the interface was thought this way to allow this implementation in the future, but currently is not implemented... is it so? In this case, I might use the same "guessing techniques" shown there in my code too. Thank you! -- Tiago Rinck Caveden http://caveden.multiply.com
See below,
Hello!
On Thu, Jun 26, 2008 at 2:29 PM, Marius Dumitru Florea < [email protected]> wrote:
Maybe this http://tinyurl.com/3hzmjd can help. It's the ActivityStream implementation for Curriki. It uses the Notification System. Take a look.
Thanks. I took a quick look, and I saw that the code there seems to be trying to guess which is the event by inspecting the objects and properties of the documents, is that right?
Unfortunately, yes.
If it is like that, why is the "event" int parameter there anyway? I thought it was his "job" to inform this.... if he always come with the same value it looks a bit weird.
I've asked my self the same question: http://tinyurl.com/66o5yz
Anyway, I'm guessing the interface was thought this way to allow this implementation in the future, but currently is not implemented... is it so?
I'd say it's rather a bug.
In this case, I might use the same "guessing techniques" shown there in my code too.
You should first take a look at Vincent's observation component. If it doesn't help then I can't see other option than to use a "guessing technique" :(
Thank you!
You're welcome! Marius
-- Tiago Rinck Caveden http://caveden.multiply.com _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Marius Dumitru Florea wrote:
In this case, I might use the same "guessing techniques" shown there in my code too.
You should first take a look at Vincent's observation component. If it doesn't help then I can't see other option than to use a "guessing technique" :(
Unfortunately that's more a stub for future use, because there aren't many events generated. Still, it is able to distinguish between create, update and delete events, which is already better. -- Sergiu Dumitriu http://purl.org/net/sergiu/
Tiago Rinck Caveden wrote:
On Wed, Jun 25, 2008 at 7:31 PM, Sergiu Dumitriu <[email protected]> wrote:
Sergiu Dumitriu wrote:
Yes, use prenotifications. This means that instead of putting the code in verify(), put it in preverify(), and use the constructor with 3 arguments. I hit Send to soon, and my notification knowledge is a bit rusty...
I mean, when creating the notification rule (DocChangeRule or whichever you're using), use the constructor with 3 arguments, and use true for the second argument, false for the third one. If the Rule doesn't have such a constructor, call setPostverify(false) and setPreverify(true). That's all you need to do.
Thanks, that helped me!
I have one more question... isn't the EVENT_UPDATE_OBJECT event code ever used? I only need to execute my code when the object in the page is changed, so I made an if with this event but then the code stopped being called. I made an Eclipse search over the variable and it didn't find any use all over XWiki's source code...
Sorry, that's a bug. See http://jira.xwiki.org/jira/browse/XWIKI-2105 -- Sergiu Dumitriu http://purl.org/net/sergiu/
participants (3)
-
Marius Dumitru Florea -
Sergiu Dumitriu -
Tiago Rinck Caveden