Modify document property during documentModified Event

Hi,

Any ideas on what I'm not doing? Basically I'm trying to update a property
of a document as it is being saved from an edit via the front-end UI. I'm
trying to do this via an EventListener, but any changes I make are not
persisted. My listener is something like:

public class MyEventListener extends AbstractEventListener implements
AsynchronousEventListener {
  public void handleEvent(CoreEvent coreEvent) throws Exception {
    String eventId = coreEvent.getEventId();
    if (eventId.equals("documentModified")) {
      doc.setProperty("myschema", "myproperty", "SOME_VALUE");
    }
  }
}

Any ideas? In my actual implementatation the value is computed from other
just entered fields - is there a better way to implement 'computed' fields?

Thanks,

Sean

--

-- 
Dr. Sean Radford, MBBS, MSc
w: http://www.tacola.com
t: 07802 24 24 86
Radu Ux D. | 19 Nov 10:21

Re: Modify document property during documentModified Event

Try with event "beforeDocumentModification". "documentModified" means, 
as the name tells, document was already saved.

Radu

sean.radford.tacola.com wrote:
> Hi,
> 
> Any ideas on what I'm not doing? Basically I'm trying to update a property
> of a document as it is being saved from an edit via the front-end UI. I'm
> trying to do this via an EventListener, but any changes I make are not
> persisted. My listener is something like:
> 
> public class MyEventListener extends AbstractEventListener implements
> AsynchronousEventListener {
>   public void handleEvent(CoreEvent coreEvent) throws Exception {
>     String eventId = coreEvent.getEventId();
>     if (eventId.equals("documentModified")) {
>       doc.setProperty("myschema", "myproperty", "SOME_VALUE");
>     }
>   }
> }
> 
> Any ideas? In my actual implementatation the value is computed from other
> just entered fields - is there a better way to implement 'computed' fields?
> 
> Thanks,
> 
> Sean
> 
(Continue reading)

Re: Modify document property during documentModified Event

Thanks, that works :D

On Wed, 19 Nov 2008 11:21:13 +0200, "Radu Ux D." <rdarlea@...> wrote:
> Try with event "beforeDocumentModification". "documentModified" means, 
> as the name tells, document was already saved.
> 
> Radu
> 
> sean.radford.tacola.com wrote:
>> Hi,
>> 
>> Any ideas on what I'm not doing? Basically I'm trying to update a
>> property
>> of a document as it is being saved from an edit via the front-end UI.
I'm
>> trying to do this via an EventListener, but any changes I make are not
>> persisted. My listener is something like:
>> 
>> public class MyEventListener extends AbstractEventListener implements
>> AsynchronousEventListener {
>>   public void handleEvent(CoreEvent coreEvent) throws Exception {
>>     String eventId = coreEvent.getEventId();
>>     if (eventId.equals("documentModified")) {
>>       doc.setProperty("myschema", "myproperty", "SOME_VALUE");
>>     }
>>   }
>> }
>> 
>> Any ideas? In my actual implementatation the value is computed from
other
(Continue reading)


Gmane