cancel
Showing results for 
Search instead for 
Did you mean: 

MailTask and ExecutionListener field injection

pitagoras
Champ in-the-making
Champ in-the-making
Hi,
I´m trying to define a listener over a mail task, with the purpose of storing the fields of a the sent mail in a local database.

So I define in my MailTask:


    <serviceTask id="sendQuoteMail" name="Send Quote" activiti:type="mail">
      <extensionElements>
        <activiti:executionListener event="start" class="delegates.MailSaver"></activiti:executionListener>
        <activiti:field name="to" expression="${quote.customer.email}"></activiti:field>
        <activiti:field name="from" expression="user@domain.com"></activiti:field>
        <activiti:field name="subject" expression="your quote ${quote.businessKey}"></activiti:field>
        <activiti:field name="html">
          <activiti:expression><![CDATA[${quote.emailString}]]></activiti:expression>
        </activiti:field>
      </extensionElements>
    </serviceTask>


And define a class:

public class MailSaver implements ExecutionListener {

   private String from;
   private String to;
   private String subject;
   private String html;
   private String text;
   

   @Override
   public void notify(DelegateExecution arg0) throws Exception {
           …
       }

        public void setFrom(String from) ….
        … and all other public gettrs and setters here…
}

I´m using activiti-engine 5.9
I tried also to bind the listener to the 'end' event.

The listener is called but no field is injected to the listener.
Am I missing something?
Thank you!
2 REPLIES 2

pitagoras
Champ in-the-making
Champ in-the-making
Well I thought I had something: I should have used Expression instead of String (as the mail task uses expressions for the fields).
Still no luck. They´re null… (the setters are not even being called…)

frederikherema1
Star Contributor
Star Contributor
You are defining the "fields" on the mail-task, not on the execution-listener… The execution-listener won't have the values injected.

Field-injection is only possible on service-tasks, your task-listener will just be called as-is.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.