Set default Listener



I’m trying to set listener when element is created. I’m using CustoemElementFactory to detect if selected element is my element. Here’s my code:

  this.create = function(elementType, attrs) {
    var type = attrs.type;

    if (elementType === 'label') {
      return self.baseCreate(elementType, assign({ type: 'label' }, LabelUtil.DEFAULT_LABEL_SIZE, attrs));

    // check if element is my element
    if (/^custom\:/.test(type)) {
      // convert my custom element to "bpmn:UserTask"
      var element = self.createBpmnElement(elementType, attrs); = "Foobar";
     // here I want to set listener 
      return element;

    return self.createBpmnElement(elementType, attrs);


Looks good. What is your question?


get the ‘moddle’ module from the bpmnDiagram and create the listener like this:

var moddle = bpmnDiagram.get('moddle');
var extensionElements = moddle.create('bpmn:ExtensionElements');
var executionListener = moddle.create('camunda:ExecutionListener');
executionListener.class = 'myCustomDelegateClassName';
executionListener.event = 'start';

now update the properties using the modeling.

var modeling = bpmnDiagram.get('modeling');
modeling.updateProperties(element, {extensionElements: extensionElements});