Flowable 6.6.0 BPMN用户指南 -9 表单 - 9.2 表单属性

《Flowable 6.6.0 BPMN用户指南》

1. 入门

2. 配置

3 The Flowable API

4 Flowable 6.6.0 BPMN用户指南 - (4)Spring集成

5 Spring Boot

6 部署

7 BPMN 2.0简介

8 BPMN 2.0的构造

9 表单(Forms)

9.1 表单定义
9.2 表单属性
9.3 外部表单渲染(External form rendering)


有关Flowable的更多文档,参见:

《Flowable文档大全》


9.2 表单属性

All information relevant to a business process is either included in the process variables themselves or referenced through the process variables. Flowable supports complex Java objects to be stored as process variables like Serializable objects, JPA entities or whole XML documents as Strings.

所有与业务流程相关的信息要么包含在流程变量中,要么通过流程变量引用。Flowable支持将复杂的Java对象存储为流程变量,如Serializable对象、JPA实体或作为字符串的整个XML文档。

Starting a process and completing user tasks is where people are involved into a process. Communicating with people requires forms to be rendered in some UI technology. In order to facilitate multiple UI technologies easy, the process definition can include the logic of transforming of the complex Java typed objects in the process variables to a Map of ‘properties’.

启动一个流程并完成用户任务是人们参与流程的地方。与人的通信需要用一些UI技术来呈现表单。为了简化多种UI技术,流程定义可包含将流程变量中复杂的Java类型对象转换为“properties”的Map的逻辑。

Any UI technology can then build a form on top of those properties, using the Flowable API methods that expose the property information. The properties can provide a dedicated (and more limited) view on the process variables. The properties needed to display a form are available in the FormData return values of for example

然后,UI技术在这些属性的基础上构建表单,使用Flowable API方法可获取相关的属性信息。属性可以提供有关流程变量的专用(和更有限的)视图。展示一个表单所需要的属性可从FormData返回值中得到,例如

StartFormData FormService.getStartFormData(String processDefinitionId)

TaskFormdata FormService.getTaskFormData(String taskId)

By default, the built-in form engine ‘sees’ the properties as well as the process variables. So there is no need to declare task form properties if they match 1-1 with the process variables. For example, with the following declaration:

默认情况下,内置表单引擎可“看到”这些属性以及流程变量。因此,如果任务表单属性与流程变量1-1匹配,则无需声明它们。例如,使用以下声明:

<startEvent id="start" />

All process variables are available when execution arrives in the startEvent, but
formService.getStartFormData(String processDefinitionId).getFormProperties()
will be empty since no specific mapping was defined.

当执行到达startEvent 时,所有流程变量都是可用的,但
formService.getStartFormData(String processDefinitionId).getFormProperties()
将为空,因为未定义指定的映射。

In the above case, all the submitted properties will be stored as process variables. This means that by simply adding a new input field in the form, a new variable can be stored.

Properties are derived from process variables, but they don’t have to be stored as process variables. For example, a process variable could be a JPA entity of class Address. And a form property StreetName used by the UI technology could be linked with an expression #{address.street}

上例中,所有提交的属性都将作为流程变量存储。这意味着只要在表单中添加一个新的输入字段,就会存储一个新的变量。

属性是从流程变量派生的,但不必存储为流程变量。例如,流程变量可以是一个Address类的JPA实体。UI技术使用的表单属性StreetName可以与表达式#{address.street}链接

Analogue, the properties that a user is supposed to submit in a form can be stored as a process variable or as a nested property in one of the process variables with a UEL value expression like e.g. #{address.street} .
Analogue the default behavior of properties that are submitted is that they will be stored as process variables unless a formProperty declaration specifies otherwise.

Also type conversions can be applied as part of the processing between form properties and process variables.
For example:

类似地,用户在表单中提交的属性可以存储为流程变量,也可以存储为一个具有UEL值表达式的流程变量中的嵌套属性,例如#{address.street} .

类似地,提交的属性的默认行为是,除非formProperty声明另有规定,否则它们将作为流程变量存储。
在进行表单属性和流程变量之间的处理时也可以应用类型转换。
例如:

<userTask id="task">
  <extensionElements>
    <flowable:formProperty id="room" />
    <flowable:formProperty id="duration" type="long"/>
    <flowable:formProperty id="speaker" variable="SpeakerName" writable="false" />
    <flowable:formProperty id="street" expression="#{address.street}" required="true" />
  </extensionElements>
</userTask>
  • Form property room will be mapped to process variable room as a String
  • Form property duration will be mapped to process variable duration as a java.lang.Long
  • Form property speaker will be mapped to process variable SpeakerName. It will only be available in the TaskFormData object. If property speaker is submitted, an FlowableException will be thrown. Analogue, with attribute readable=“false”, a property can be excluded from the FormData, but still be processed in the submit.
  • Form property street will be mapped to Java bean property street in process variable address as a String. And required=“true” will throw an exception during the submit if the property is not provided.
  • 表单属性room将作为字符串映射到流程变量room
  • 表单属性duration将映射到java.lang.Long类型的流程变量duration,
  • 表单属性speaker将映射到流程变量SpeakerName。它只在TaskFormData对象中可用。如果提交属性speaker,则将引发FlowableException。类似地,当属性readable=“false”时,可从FormData中排除一个属性,但仍可以在提交中进行处理。
  • 表单属性street将作为字符串映射到流程变量address中的Java bean 属性street。如果未提供此属性,且因为required=“true”,将在提交时引发异常。

It’s also possible to provide type metadata as part of the FormData that is returned from methods StartFormData FormService.getStartFormData(String processDefinitionId) and TaskFormdata FormService.getTaskFormData(String taskId)

We support the following form property types:

  • string (org.flowable.engine.impl.form.StringFormType
  • long (org.flowable.engine.impl.form.LongFormType)
  • double (org.flowable.engine.impl.form.DoubleFormType)
  • enum (org.flowable.engine.impl.form.EnumFormType)
  • date (org.flowable.engine.impl.form.DateFormType)
  • boolean (org.flowable.engine.impl.form.BooleanFormType)

还可以提供类型元数据作为FormData的一部分。从StartFormData FormService.getStartFormData(String processDefinitionId) 和 TaskFormdata FormService.getTaskFormData(String taskId)返回FormData。

我们支持以下表单属性类型:

  • string (org.flowable.engine.impl.form.StringFormType
  • long (org.flowable.engine.impl.form.LongFormType)
  • double (org.flowable.engine.impl.form.DoubleFormType)
  • enum (org.flowable.engine.impl.form.EnumFormType)
  • date (org.flowable.engine.impl.form.DateFormType)
  • boolean (org.flowable.engine.impl.form.BooleanFormType)

For each form property declared, the following FormProperty information will be made available through List formService.getStartFormData(String processDefinitionId).getFormProperties() and List formService.getTaskFormData(String taskId).getFormProperties()

对于声明的每个表单属性,将通过List formService.getStartFormData(String processDefinitionId).getFormProperties() 和List formService.getTaskFormData(String taskId).getFormProperties()获取下述FormProperty信息。


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();
}

For example:

<startEvent id="start">
  <extensionElements>
    <flowable:formProperty id="speaker"
      name="Speaker"
      variable="SpeakerName"
      type="string" />

    <flowable:formProperty id="start"
      type="date"
      datePattern="dd-MMM-yyyy" />

    <flowable:formProperty id="direction" type="enum">
      <flowable:value id="left" name="Go Left" />
      <flowable:value id="right" name="Go Right" />
      <flowable:value id="up" name="Go Up" />
      <flowable:value id="down" name="Go Down" />
    </flowable:formProperty>

  </extensionElements>
</startEvent>

All that information is accessible through the API. The type names can be obtained with formProperty.getType().getName(). And even the date pattern is available with formProperty.getType().getInformation(“datePattern”) and the enumeration values are accessible with formProperty.getType().getInformation(“values”)

The following XML snippet

所有这些信息都可以通过API访问。类型名称可以通过formProperty.getType().getName()获取。日期模式也可以通过formProperty.getType().getInformation(“datePattern”)获取,枚举值可通过ormProperty.getType().getInformation(“values”)获取。

下面的XML片段

<startEvent>
  <extensionElements>
    <flowable:formProperty id="numberOfDays" name="Number of days" value="${numberOfDays}" type="long" required="true"/>
    <flowable:formProperty id="startDate" name="First day of holiday (dd-MM-yyy)" value="${startDate}" datePattern="dd-MM-yyyy hh:mm" type="date" required="true" />
    <flowable:formProperty id="vacationMotivation" name="Motivation" value="${vacationMotivation}" type="string" />
  </extensionElements>
</userTask>

could be used to render to a process start form in a custom app.

可用于在自定义应用程序中渲染出一个流程启动窗体。

你可能感兴趣的:(Flowable,6.6.0,BPMN用户指南,-9-11)