There are currently no less than three ways to include forms in your Activiti workflows. #####Activit Form Types
- Use the standard Activiti form properties and have them automatically rendered in a generic fashion by our UI
- Explicitly define a custom page to render it (and add other functionality), by embedding in the process definition (which ends up as ugly, hard to edit XML escaped HTML code)
- Explicitly define a custom page to render it (and add other functionality), by using a 'form' defined in the UI artifacts, referenced via the formKey. This uses the regular UI templates/function libraries we have built, so it is very powerful and we provide some good high level functions and patterns to add fields etc, but with power also comes an amount of complexity.
Each method has advantages and disadvantages.
#####Activiti Forms
Advantages
- Quick and easy for simple use cases
- No HTML form is required, form is rendered n the fly from the Activiti defined form fields
Disadvantages
- Limited to Activiti form schema, for example, there is no password form field type, so passwords appear in clear test instead of bullets
- Limited functionality since there is no HTML form, there can be no JavaScript code to hook into product features
#####_formGenerationTemplate
Advantages
- Easy to embed in BPMN XML with custom builder now and part of default behavior in v3.0
- JavaScript code can be used to access product features like realtime password strength evaluation
Disadvantages
- In v2.x, default behavior is to require XML escaped HTML which is ugly and hard to read and modify
#####formKey
Advantages
- Deepest integration into the OpenIDM UI Framework
- Lets forms be defined outside the Activiti BPMN XML file
Disadvantages
- Deepest integration into the OpenIDM UI Framework
- Must know our UI framework (JQuery, Backbone, Mustache)
I have written a custom Eclipse Project Builder script that simplifies option 2 above. To use this custom builder do the following: #####Create Custom Builder
- Start with an Activiti BPMN XML file (which can be auto generated by the Activiti Designer Plugin or you can start with a copy of an existing one)
- Make sure the file name ends in *.bpmn and not bpmn20.xml
- Replace the XML escaped HTML code with anchors like %PROCFORM% or %TASKFORM$:
<activiti:formProperty id="_formGenerationTemplate" type="string" default="%PROCFORM%"></activiti:formProperty>
-
Create *.proc.html and *.task.html web form files (you can copy and unescape the form from a sample file)
-
To make a new *.bpmn20.xml file, just run the custom builder (Projects -> Build Project, when prompted, double click the *.bpmn file). #####Note The custom builder called insertXML.sh which calls HTML2XML.sh, replaces the anchors with properly escaped HTML code, and creates a new *.bpmn20.xml file. To create the custom builder in Eclipse:
-
Download the necessary shell scripts. (Warning, there is different code in insertXML.sh for MacOS and Linux. You may have to comment/uncomment accordingly)
-
Unzip and place the scripts in an OpenIDM directory like /opt/openidm/samples/workflow/workflow
-
In Eclipse, go to Project -> Properties
-
Click "Builders" on the left pane.
-
Click "New" button
-
Select "Program"
-
Under "location", enter the path to the script
-
Under "Working Directory", enter the path to the directory with the *.bpmn, *.proc.html and *.task.html file
-
Click the "Varinables" button
-
Select "file_prompt" (no arguments are required)
-
Click OK
-
Name the Builder whatever you like
-
Click OK