[xwiki-devs] DocumentUpdatingEvent() new object values
Hi devs, I'm having trouble with a listener to DocumentUpdatingEvent. I need to add new objects to my document, depending on the new values of some fields of an already existing object. The problem is that, because the document is not saved yet, I can only see the old values of the fields but I can't see the changes that were made. Is there a method to get the new values? I could use DocumentUpdatedEvent and see only the values but I would like to avoid saving the document twice. Thanks, Vlad
On Thu, Aug 4, 2011 at 4:16 PM, Vlad Merticariu <[email protected]> wrote:
Hi devs,
I'm having trouble with a listener to DocumentUpdatingEvent.
I need to add new objects to my document, depending on the new values of some fields of an already existing object. The problem is that, because the document is not saved yet, I can only see the old values of the fields but I can't see the changes that were made. Is there a method to get the new values?
I could use DocumentUpdatedEvent and see only the values but I would like to avoid saving the document twice.
That's weird, as far as I can see in the code the exact same XWikiDocument object is given to both DocumentUpdatingEvent and DocumentUpdatedEvent events. If you have a way for us to easily reproduce the behavior you get you should create an issue on http://jira.xwiki.org and details it there so that we can try to debug it.
Thanks, Vlad _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On 08/04/2011 10:16 AM, Vlad Merticariu wrote:
Hi devs,
I'm having trouble with a listener to DocumentUpdatingEvent.
I need to add new objects to my document, depending on the new values of some fields of an already existing object. The problem is that, because the document is not saved yet, I can only see the old values of the fields but I can't see the changes that were made. Is there a method to get the new values?
Where exactly are you looking for those values? You're supposed to use the argument passed to the listener, and not try to get them from the database (or from the document access bridge).
I could use DocumentUpdatedEvent and see only the values but I would like to avoid saving the document twice.
Thanks, Vlad
-- Sergiu Dumitriu http://purl.org/net/sergiu/
Where exactly are you looking for those values? You're supposed to use the argument passed to the listener, and not try to get them from the database (or from the document access bridge).
That was indeed my problem, I was getting the values from the database; crossed my mind when Thomas told me that the same document is returned both by DocuemntUpdating and DocumentUpdated. Thanks, Vlad On Fri, Aug 12, 2011 at 4:23 AM, Sergiu Dumitriu <[email protected]> wrote:
On 08/04/2011 10:16 AM, Vlad Merticariu wrote:
Hi devs,
I'm having trouble with a listener to DocumentUpdatingEvent.
I need to add new objects to my document, depending on the new values of some fields of an already existing object. The problem is that, because the document is not saved yet, I can only see the old values of the fields but I can't see the changes that were made. Is there a method to get the new values?
Where exactly are you looking for those values? You're supposed to use the argument passed to the listener, and not try to get them from the database (or from the document access bridge).
I could use DocumentUpdatedEvent and see only the values but I would like to avoid saving the document twice.
Thanks, Vlad
-- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
participants (3)
-
Sergiu Dumitriu -
Thomas Mortagne -
Vlad Merticariu