cancel
Showing results for 
Search instead for 
Did you mean: 

FormService should be support for Object type value

kafeitu
Champ on-the-rise
Champ on-the-rise
ProcessInstance   submitStartFormData(String processDefinitionId, Map<String,String> properties)
          Start a new process instance with the user data that was entered as properties in a start form.

ProcessInstance   submitStartFormData(String processDefinitionId, String businessKey, Map<String,String> properties)
          Start a new process instance with the user data that was entered as properties in a start form.

void   submitTaskFormData(String taskId, Map<String,String> properties)
          Completes a task with the user data that was entered as properties in a task form.

Now, use FormService to submit datas that should be String, why not support for Object?

For example, start a process instance that contains a multi instance task, and the Collections use expression ${users}. So use code of below to start a process instance.


String users = "user1,user2,user3,user4";
    String processDefinitionId = processDefinition.getId();
   
    Map<String, String> formProperties = new HashMap<String, String>();
    formProperties.put("countersignUsers", users);
   
    ProcessInstance processInstance = formService.submitStartFormData(processDefinitionId, formProperties);

Then occur a exception: org.activiti.engine.ActivitiException: ${countersignUsers}' didn't resolve to a Collection

——————-
Use RuntimeService.startProcessInstanceBy* method are ok.


    Map<String, Object> variableMap = new HashMap<String, Object>();

    List<String> users = Arrays.asList("user1", "user2", "user3", "user4");
    variableMap.put("countersignUsers", users);
    variableMap.put("rate", rate);

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dispatch", variableMap);
    assertNotNull(processInstance.getId()); // it's ok

So, i hope on the FormService's method that name start with submit to support Object type value.

JIRA: http://jira.codehaus.org/browse/ACT-1412

—————
I created a branch form-properties-support-object-value, details: https://github.com/henryyan/Activiti/commit/15f86de0b6d6e0eea3488c0da621f76647871174
All unit tests valid and my question has been resolved too.
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
Form-properties were delibiratly String-typed and the conversion to actual Object's in built-in in FormTypes. So if you want to add a type that converts e.g.. a comma-separated list of values in a form-proprty to an object-array, you'll have to write an plug in your own custom form-proprty type.

Have a look at: org.activiti.explorer.form.UserFormType for an example on how to create one, and look in the /activiti-webapp-explorer2/src/main/webapp/WEB-INF/applicationContext.xml how to wire it.

kafeitu
Champ on-the-rise
Champ on-the-rise
Form-properties were delibiratly String-typed and the conversion to actual Object's in built-in in FormTypes. So if you want to add a type that converts e.g.. a comma-separated list of values in a form-proprty to an object-array, you'll have to write an plug in your own custom form-proprty type.

Have a look at: org.activiti.explorer.form.UserFormType for an example on how to create one, and look in the /activiti-webapp-explorer2/src/main/webapp/WEB-INF/applicationContext.xml how to wire it.

Thanks for your reply, try it now.