cancel
Showing results for 
Search instead for 
Did you mean: 

No Default field for form properties in Activti Modeler

mf
Confirmed Champ
Confirmed Champ
I want to set default value for a StartForm form property. Based on  ACT-1028 it's possible since 5.10 version. But in Activiti Modeler i can't find any Default (or DefaultExpression) field column in form properties editor. Is there any trick to do this with modeler? I'm using activiti-5.14.

[img]http://upload7.ir/imgs/2014-09/34378440169193546927.png[/img]

Thanks
2 REPLIES 2

trademak
Star Contributor
Star Contributor
I think that's missing right now. Can you raise a JIRA issue?

Thanks,

mf
Confirmed Champ
Confirmed Champ

I'v raised a JIRA issue ( ACT-2117) about this.
But to solve this problem i patched "org.activiti.engine.impl.form.FormPropertyHandler#createFormProperty" to read value of expresion if execution was null:

  /*
   * Patched for StartForm form properties default value support,
   * No default column exists in Activiti Modeler to set default value for form property
   */

  public FormProperty createFormProperty(ExecutionEntity execution) {
    FormPropertyImpl formProperty = new FormPropertyImpl(this);
    Object modelValue = null;
   
    if (execution!=null) {
      if (variableName != null || variableExpression == null) {
        final String varName = variableName != null ? variableName : id;
        if (execution.hasVariable(varName)) {
          modelValue = execution.getVariable(varName);
        } else if (defaultExpression != null) {
          modelValue = defaultExpression.getValue(execution);
        }
      } else {
        modelValue = variableExpression.getValue(execution);
      }
    } else {
      // Execution is null, the form-property is used in a start-form. Default value
      // should be available (ACT-1028) even though no execution is available.
      if (defaultExpression != null) {
        modelValue = defaultExpression.getValue(StartProcessVariableScope.getSharedInstance());
      }
      // Patched for StartForm form properties default value support.
      else if(variableExpression != null) {
       modelValue = variableExpression.getValue(execution);
      }
    }

    if (modelValue instanceof String) {
      formProperty.setValue((String) modelValue);
    } else if (type != null) {
      String formValue = type.convertModelValueToFormValue(modelValue);
      formProperty.setValue(formValue);
    } else if (modelValue != null) {
      formProperty.setValue(modelValue.toString());
    }
   
    return formProperty;
  }