Select boxes are HTML controls of the form of

  1. <select></select>

Binding to a Process Variable

A select box can be bound to a process variable using the cam-variable-name directive:

  1. <select cam-variable-name="foo"
  2. cam-variable-type="String">
  3. <option>bar</option>
  4. <option>zar</option>
  5. </select>

Supported Variable Types

The select box supports the same value types as <input type="text">.

Populating the Options from a Variable

The <option> entries can be populated using a variable. The name of the variable can be provided using the cam-choices directive:

  1. <select cam-variable-name="PRODUCT_TYPE"
  2. cam-variable-type="String"
  3. cam-choices="AVAILABLE_PRODUCT_TYPES">
  4. </select>

The directive cam-choices expects the values to be a List or Map (Object). In case of a Map (Object), the keys of the map are used as values of the options. java.util.Map and java.util.List are supported but must be serialized as JSON:

  1. Map<String, String> productTypes = new HashMap<String, String>();
  2. productTypes.put("001", "Notebook");
  3. productTypes.put("002", "Server");
  4. productTypes.put("003", "Workstation");
  5. execution.setVariable("AVAILABLE_PRODUCT_TYPES",
  6. objectValue(customerData)
  7. .serializationDataFormat(SerializationDataFormats.JSON)
  8. .create());

Would be rendered as

  1. <select cam-variable-name="PRODUCT_TYPE"
  2. cam-variable-type="String"
  3. cam-choices="AVAILABLE_PRODUCT_TYPES">
  4. <option value="001">Notebook</option>
  5. <option value="002">Server</option>
  6. <option value="003">Workstation</option>
  7. </select>

原文: https://docs.camunda.org/manual/7.9/reference/embedded-forms/controls/select/