AnsweredAssumed Answered

Extends EnumFormType

Question asked by marcantoine on Nov 12, 2014
Latest reply on Dec 16, 2014 by marcantoine

I wan't to create a new custom form type.
I need a list a values (list of companies available on a database).
For that I want to create an type based on EnumFormType. I can create a new type in may form and it will appear correctly loaded (not via activiti-explorer but via activiti-rest - I think it's a library dependency problem for that)

But after looking the bpmn20.xml, the parameter will not have values. Is it possible to access to them using the Rest API ?

I have wrote this code:

import java.util.HashMap;
import java.util.Map;

import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.impl.form.EnumFormType;

public class C4MCompaniesFormType extends EnumFormType {
  static Map<String, String> getCompagnies(){
     Map<String, String> companies;
     companies = new HashMap<String, String>();
     companies.put("companyId1", "Company name 1");
     companies.put("companyId2", "Company Name 2");
     return companies;
  public C4MCompaniesFormType() {
  public C4MCompaniesFormType(Map<String, String> companies) {
  public String getName() {
    return "companies";

  public Object getInformation(String key) {
     System.out.println( "getInformation : " + key );
    if (key.equals("values")) {
      return getCompagnies();
    return null;
  public Object convertFormValueToModelValue(String propertyValue) {
   System.out.println( "convertFormValueToModelValue : " + propertyValue );
   return propertyValue;

  public String convertModelValueToFormValue(Object modelValue) {
   System.out.println( "convertModelValueToFormValue : " + modelValue );
   if(modelValue != null) {
     if(!(modelValue instanceof String)) {
       throw new ActivitiIllegalArgumentException("Model value should be a String");
     validateValue((String) modelValue);
   return (String) modelValue;
  protected void validateValue(String company) {
   Map<String, String> companies = getCompagnies();
   if(company != null) {
     if(companies != null && !companies.containsKey(company)) {
       throw new ActivitiIllegalArgumentException("Invalid value for companies form property: " + company);