protected String variableName;
protected Expression variableExpression;
protected Expression defaultExpression;
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());
}
}
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;
}