Difference between revisions of "HTML Presentation Object: BPMN Diagram"

From Mea Wiki
Jump to navigation Jump to search
Line 15: Line 15:
  
 
<script>
 
<script>
  var exampleModeler = new bpmnModeler({
+
var exampleModeler = new bpmnModeler({
    container: '#canvas<#uniqueId>',
+
  container: '#canvas<#uniqueId>',
      keyboard: {
+
    keyboard: {
        bindTo: window
+
      bindTo: window
      }
+
    }
    });
+
});
  
 
// Definition of empty model canvas
 
// Definition of empty model canvas
Line 39: Line 39:
 
// Import model
 
// Import model
 
exampleModeler.importXML(bpmnModel, function(err) {
 
exampleModeler.importXML(bpmnModel, function(err) {
      if (err != null) { alert("Error in importing BPMN XML. The file doesn't seem to be valid. More information: " + err.message); return; }
+
  if (err != null) { alert("Error in importing BPMN XML. The file doesn't seem to be valid. More information: " + err.message); return; }
 
});
 
});
 
</script>
 
</script>

Revision as of 08:57, 9 June 2018

This is an example on how to use the available BPMN.io library in an HTML presentation object:

To use the library, do as follows:

  1. Create a view and a panel.
  2. Add an HTML presentation object to the panel. Use the below defined code for the HTML presentation object.
<div id="canvas<#uniqueId>"></div>

<style>
  #canvas<#uniqueId> {
    height: 100%;
  }
</style>

<script>
var exampleModeler = new bpmnModeler({
  container: '#canvas<#uniqueId>',
    keyboard: {
      bindTo: window
    }
});

// Definition of empty model canvas
var bpmnModel ='<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://www.omg.org/spec/BPMN/2.0/20100501/BPMN20.xsd">
  <process id="Process_1n1ursk" />
  <bpmndi:BPMNDiagram id="sid-74620812-92c4-44e5-949c-aa47393d3830">
    <bpmndi:BPMNPlane id="sid-cdcae759-2af7-4a6d-bd02-53f3352a731d" bpmnElement="Process_1n1ursk" />
    <bpmndi:BPMNLabelStyle id="sid-e0502d32-f8d1-41cf-9c4a-cbb49fecf581">
      <omgdc:Font name="Arial" size="11" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" />
    </bpmndi:BPMNLabelStyle>
    <bpmndi:BPMNLabelStyle id="sid-84cb49fd-2f7c-44fb-8950-83c3fa153d3b">
      <omgdc:Font name="Arial" size="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" />
    </bpmndi:BPMNLabelStyle>
  </bpmndi:BPMNDiagram>
</definitions>';

// Import model
exampleModeler.importXML(bpmnModel, function(err) {
  if (err != null) { alert("Error in importing BPMN XML. The file doesn't seem to be valid. More information: " + err.message); return; }
});
</script>