天天看點

Flowable 6.6.0 BPMN使用者指南 -9 表單 - 9.2 表單屬性《Flowable 6.6.0 BPMN使用者指南》

Flowable 6.6.0 使用者指南相關文檔下載下傳

  • BPMN使用者指南 第一部分 - 中文PDF精編版
  • BPMN使用者指南 第二部分 - 中文PDF精編版
  • BPMN使用者指南 第三部分 - 中文PDF精編版
  • 應用程式指南 - 中文PDF精編版
  • 應用程式指南 - 中英對照PDF精編版
  • 應用程式指南 - Eclipse設計器中文PDF精編版
  • 表單使用者指南 - 中文PDF精編版
  • 事件系統資料庫使用者指南 - 中文PDF精編版

《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<String,String> of ‘properties’.

啟動一個流程并完成使用者任務是人們參與流程的地方。與人的通信需要用一些UI技術來呈現表單。為了簡化多種UI技術,流程定義可包含将流程變量中複雜的Java類型對象轉換為“properties”的Map<String,String>的邏輯。

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傳回值中得到,例如

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比對,則無需聲明它們。例如,使用以下聲明:

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.

可用于在自定義應用程式中渲染出一個流程啟動窗體。

繼續閱讀