This is a KIE Server dialect for jBPM business applications (start.jbpm.org) used with integration with Thymeleaf.
It provides a set of directives to easily interact with many services exposed in your jBPM business application straight in your Thymeleaf html templates. It is really easy to install and it eliminates the need for you to write integration code for some functionalities provided. The dialect is also extendable so you control the display of the resulting information.
SpringBoot 2 support added! This dialect now works out of box with jBPM Business applications generated with start.jbpm.org (versions 1.8 or greater) which are generated using SpringBoot version 2.
Once you have created your business appliation on start.jbpm.org you can easily install this dialect in just a single step:
- In your service module pom.xml add dependency:
<dependency>
<groupId>org.jbpm.addons</groupId>
<artifactId>thymeleaf-kie-server-dialect</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
And that's it! You are now ready to start using the dialect in your Thymeleaf templates!
- Kie Server dialect by default produces html which includes some boostrap style class names and js functions. In order for those to work you need to add the boostrap style and js and jquery to your page section, for example:
<head>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"
/>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
You are however not bound to use the default generated html and can create your own display of the resulting information. For this see the "Creating your own display" section.
- All dialect tags start with <kieserver:.../> and you can define this as namespace as an attribute in your page tag (note this step is optional):
<html
xmlns:th="http://www.thymeleaf.org"
xmlns:kieserver="http://jbpm.org/"
></html>
Now that you have set everything up here is how you can use the dialect
In the body section of your template add:
<kieserver:processdefs />
This will generate a table on your page displaying all processes that are defined and registered, for example:
You can start a process intsance by clicking on the "Start" action button. This will open the process form where you can enter in process data defined in the form and start the business process.
In the body section of your template add:
<kieserver:deployments />
This will display info for all deployment units:
You can also pass a deployment unit id parameter to show info for a specific deployment unit:
<kieserver:deployments deploymentid="${deploymentid}" />
In the body section of your template add:
<kieserver:processinstances />
This will display info table with all available process instances:
If the task instance contains Tasks that can be worked on will be displayed in the "Work on Tasks" column. Each is a link which when clicked will open up the task form modal which includes the task form and buttons with which you can advance the user task.
In the body section of your template add:
<kieserver:processimages />
This will display a dropdown table with a list of process instances. If there are no process instances available the dropdown will be empty. You an pick a process instance id from the dropdown which will then display the annotated process instance image, for example:
In the body section of your page add:
<kieserver:startprocess
processid="${processid}"
containerid="${containerid}"
processinputs="${processinputs}"
/>
where ${processid} ${containerid} and processinputs are your Model attributes added in the @Get mapping of your template.
Notes:
-
processid and containerid attributes can also accept hard-coded string values where as processinput has to be an expression mapping to a Map<String, Object> model object.
-
processid and containerid are required attributes, where processinputs is optional (in case your process started does not take any input).
When your page is being parsed by Thymeleaf the business process will be started. and the output will be an alert, for example:
In the body section of your page add:
<kieserver:abortprocess
deploymentid="${deploymentid}"
processinstanceid="${processinstanceid}"
/>
where ${deploymentid} ${processinstanceid} and processinputs are your Model attributes added in the @Get mapping of your template.
Notes:
- deploymentid and processinstanceid attributes can also accept hard-coded string values
- deploymentid and processinstanceid are required attributes
In the body section of your page add:
<kieserver:signalprocess
deploymentid="${deploymentid}"
processinstanceid="${processinstanceid}"
signalname="${signalname}"
event="${event}"
/>
where ${deploymentid} ${processinstanceid} ${signalname} ${event} and processinputs are your Model attributes added in the @Get mapping of your template.
Notes:
- deploymentid and processinstanceid attributes can also accept hard-coded string values, event has to be an expression resolving to an Object type variable
- deploymentid and processinstanceid and signalname are required attributes, event is optional
All dialect directives shown so far can take an extra attribute called "fragment" which you can use to control their display. We use Thymeleaf fragments (reusable components) for the display of each directive, you can find them in a single file here. With the "fragment" attribute you can change the default fragment name used to one you define yourself. Here are the steps to do this:
-
In your business application create an html file that will hold your fragments, for example /src/main/resources/templates/mykiedialectfragments.html.
-
Let's say you want to have your own display of the results of
<kieserver:processdefs />
In your mykiedialectfragments.html add:
<div th:fragment="myprocessdefs">
... YOUR CODE HERE ...
</div>
- Tell the dialect directive to use your own fragment:
<kieserver:processdefs fragment="${myfragment}" />
where ${myfragment} can be a model attribute or a hard-coded string, for this example the value should be "mykiedialectfragments :: myprocessdefs".
And that's it, you now control the display completely.