1. Problem elaboration
Typically, each “user task” corresponds to a form for the user to enter information into. Especially when there are multiple versions of the “process definition”, explicitly specifying the form is extremely important. A new version of the process definition usually has the following effects on forms:
- A link (user task) is added, which is then followed by a form, along with scripts, styles, and Web apis;
- Deleted link (user task), at this time can not be ignored, in order to take into account the old version of the process definition, its corresponding form should be retained, and cannot be deleted;
- Modify the link (user tasks), as in the two fields, have been added to A link in B section reduces the two fields at the same time, at this moment for A, B two links to create A form, to create their script, style, and to create A Web API, because the form has changed, so business is also changed, SQL (table) is changed accordingly.
2. Form association scheme
To make it easy for a particular link (user task) to find its own Form, we can use Form Key associations:
The name of the form can be read when the user task is processed:
TaskFormData formData = formService.getTaskFormData(taskId);
String formKey = formData.getFormKey();
Copy the code
Or for the start process phase, you can read the form name as follows:
formService.getStartFormData(String processDefinitionId).getFormKey();
Copy the code
3. Client rendering
If the form page is a separate main page, you can jump directly to it:
var url = formKey + "? id=" +objId + "&taskId=" +taskId;
window.location.href = url;
Copy the code
If the form page is a partial view (which could still be.jsp), fill the formKey with placeholder {0} based on the JSP EL expression:
<jsp:include page=".. /.. /shared/Partial/{0}.jsp" flush="true"/>
Copy the code
The same applies to scripts and styles. In JSP, when a path is a variable, the following is used:
<% String add = "/includes/" + id + "/abc.html"; % ><jsp:include page="<%= add %>"></jsp:include>
Copy the code
Go to this Activiti user task associated with a custom form introduction to complete.