Hi
I tried to dynamically change the colors of the BPMN elements in my BPMN model using the Java API
(I use SpringBoot , Java 8, camunda-bpm-spring-boot-starter)
I read the DomDocument from the modelInstance and than I try to change the color of some of the elements at runtime, for example
1 BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);
2 DomDocument document = modelInstance.getDocument();
3 DomElement domElement = document.getElementById(“Start_01”);
4 domElement.setAttribute(“bioc:stroke”, “#34db48”); // green
5 domElement.setAttribute(“bioc:fill”, “#34db48” );
At line 3 I select the BPMNShape
bpmndi:BPMNShape id="Start_01" bpmnElement="Start"
and than I try to set the bioc:stroke/bioc:fill atrributes which contain the colors for the element
My expectation was that after line 4/5 I get the follwong code
bpmndi:BPMNShape id=“Start_01” bpmnElement=“Start” bioc:stroke=“#34db48” bioc:fill=“#34db48”
But line 4 throws an exception
at java.lang.Thread.run(Thread.java:745)
Caused by: org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.checkDOMNSErr(CoreDocumentImpl.java:2547)
at com.sun.org.apache.xerces.internal.dom.AttrNSImpl.setName(AttrNSImpl.java:117)
at com.sun.org.apache.xerces.internal.dom.AttrNSImpl.(AttrNSImpl.java:78)
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.createAttributeNS(CoreDocumentImpl.java:2164)
at com.sun.org.apache.xerces.internal.dom.ElementImpl.setAttributeNS(ElementImpl.java:659)
at org.camunda.bpm.model.xml.impl.instance.DomElementImpl.setAttribute(DomElementImpl.java:244)
at org.camunda.bpm.model.xml.impl.instance.DomElementImpl.setAttribute(DomElementImpl.java:231)
at org.camunda.bpm.model.xml.impl.instance.DomElementImpl.setAttribute(DomElementImpl.java:227)
How can I solve this?
Cheers Roland