In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to understand forms and applications in Activiti". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to understand the forms and applications in Activiti.
Forms in Activiti
Activiti provides a convenient and flexible way to manually add forms to business processes
There are two ways to support forms:
Render the built-in form through form properties
Render the external form through the form properties
Form Properties
All information associated with the business process:
Contains its own process variables
Through the reference of the process variable
Activiti supports storing complex Java objects as process variables:
Serialize object
Jpa entity object
The entire XML document as a string
The user interacts with the process when starting a process and completing user tasks
The form needs some UI technology to render before it can interact with the user.
To make it easy to use different UI technologies, the process definition includes a logic for converting complex Java type objects in process variables to a properties Map type
Use the Activiti API method to view the exposed property information. Any UI technology can then build a form on top of these attributes. This property specifically provides a view of the process variables. The properties to be displayed by the form can be obtained from the return value FormData:
StartFormData FormService.getStartFormData (String processDefinitionId)
Or
TaskFormdata FormService.getTaskFormData (String taskId)
By default, the built-in form engine encounters these variables as if it were process variables. If there is an one-to-one relationship between task form properties and process variables, then task form properties do not need to be declared:
All process variables are available when the start event is executed, but
FormService.getStartFormData (String processDefinitionId) .getFormProperties ()
Will be a null value because there is no specific mapping defined
All submitted properties in the form will be stored as process variables in the database used by Activiti. This means that a simple input input field is added to a form and will also be stored as a new variable
Properties come from process variables, but do not have to be stored as process variables:
A process variable may be a JPA entity such as class Address. The form attribute StreetName used in some UI technology may be associated with an expression # {address.street}
Form properties submitted by users should be stored as process variables
Use a Uel value expression to store it as a nested attribute of a process variable
The default behavior of submitted form properties is to store them as process variables, unless a formProperty declares other rules
Type conversions can also be applied to processing between form data and process variables:
The form property room will be mapped to the String type process variable room
The form property duration will be mapped to the java.lang.Long type process variable duration
The form property speaker will be mapped to the process variable SpeakerName:
Writable= "false" can only be used in TaskFormData objects. If the property speaker is submitted, an exception of ActivitiException will be thrown
Readable= "false" this attribute is excluded from FormData, but it is still processed after submission
The form property street will be mapped to the property street of Java Bean address as a process variable of type String:
When the submitted form property is not provided and required= "true", an exception is thrown
Form data can also provide type metadata as part of FormData. The FormData can be obtained from the return values of the following methods:
StartFormData FormService.getStartFormData (String processDefinitionId) TaskFormdata FormService.getTaskFormData (String taskId)
Form property type:
String: org.activiti.engine.impl.form.StringFormType
Long: org.activiti.engine.impl.form.LongFormType
Enum: org.activiti.engine.impl.form.EnumFormType
Date: org.activiti.engine.impl.form.DateFormType
Boolean: org.activiti.engine.impl.form.BooleanFormType
For declaring each form property, the FormProperty information can be obtained in the following ways:
List formService.getStartFormData (String processDefinitionId) .getFormProperties ()
Or
List formService.getTaskFormData (String taskId) .getFormProperties ()
Public interface FormProperty {/ * * the key used to submit the property in {@ link FormService#submitStartFormData (String, java.util.Map)} * or {@ link FormService#submitTaskFormData (String, java.util.Map)} * / String getId (); / * the display label * / String getName (); / * one of the types defined in this interface like e.g. {@ link # TYPE_STRING} * / FormType getType () / * * optional value that should be used to display in this property * / String getValue (); / * is this property read to be displayed in the form and made accessible with the methods * {@ link FormService#getStartFormData (String)} and {@ link FormService#getTaskFormData (String)}. * / boolean isReadable (); / * is this property expected when a user submits the form? * / boolean isWritable (); / * is this property a required input field * / boolean isRequired ();}
Example:
The information for all form properties is accessible through API:
FormProperty.getType () .getName (): gets the name of the type
FormProperty.getType (). GetInformation ("datePattern"): how to get a date match
FormProperty.getType () .getInformation ("values"): you can get the enumerated value
The Activiti console supports form properties and can render the form based on the form definition:
When using the Activiti console, it is rendered as a startup form for the process
Rendering of external form
API in Activiti allows task forms to be rendered in ways other than Activiti process engine, and task forms can be rendered in a custom way
There are two service methods for assembling all the form properties that need to be rendered:
StartFormData FormService.getStartFormData (String processDefinitionId)
TaskFormdata FormService.getTaskFormData (String taskId)
There are two ways to submit form properties:
ProcessInstance FormService.submitStartFormData (String processDefinitionId, Map properties)
Void FormService.submitStartFormData (String taskId, Map properties)
You can put any form template resource into the business document you want to deploy (if you want to store it according to the version of the process). Will be used as an available resource in deployment
There are two ways to get a deployment form template:
String ProcessDefinition.getDeploymentId ()
InputStream RepositoryService.getResourceAsStream (String deploymentId, String resourceName)
In this way, you can get the form template definition file, and you can render or display the form in the application
You can also use this feature to obtain deployment resources other than the task form for other purposes
Attribute
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.