AnsweredAssumed Answered

Null values handling for submit form

Question asked by heven on Sep 12, 2012
Latest reply on Oct 22, 2012 by jbarrez
Hello,

I implemented a custom form type for my user task.
During a FormService.submitTaskFormData I want to set this specific property to null, therefore I add the form property id and a null value to the map which is used for the submitTaskFormData call.
My convertFormValueToModelValue method of my AbstractFormType implementation is executed where I return null In case the propertyValue is null but the null value is never set to the variable of my form property.

A look at the FormPropertyHandler.submitFormProperty code shows that the value is only stored to variables or variable expressions when it is not null.

    if (modelValue != null) {
      if (variableName != null) {
        execution.setVariable(variableName, modelValue);
      } else if (variableExpression != null) {
        variableExpression.setValue(modelValue, execution);
      } else {
        execution.setVariable(id, modelValue);
      }
    }


This doesn’t make much sense for me. Why do you prevent null values?
Is there a way to change this behavior without changing the activiti code?

Outcomes