public virtual IFormField CreateFormField(ExecutionEntity executionEntity) { var formField = new FormFieldImpl(); // set id formField.Id = id; // set label (evaluate expression) //IVariableScope variableScope = executionEntity != null // ? executionEntity // : StartProcessVariableScope.SharedInstance; if (label != null) { //var labelValueObject = label.getValue(variableScope); //if (labelValueObject != null) //{ // formField.Label = labelValueObject.ToString(); //} } formField.BusinessKey = businessKey; // set type formField.Type = Type; // set default value (evaluate expression) object defaultValue = null; if (defaultValueExpression != null) { //defaultValue = defaultValueExpression.getValue(variableScope); //if (defaultValue != null) //{ // formField.DefaultValue = type.convertFormValueToModelValue(defaultValue); //} //else //{ // formField.DefaultValue = null; //} } // value //ITypedValue value = variableScope.getVariableTyped(id); //if (value != null) //{ // formField.Value = type.convertToFormValue(value); //} // properties formField.Properties = properties; // validation var validationConstraints = formField.ValidationConstraints; foreach (var validationHandler in validationHandlers) { if (!"validator".Equals(validationHandler.name)) { validationConstraints.Add(validationHandler.CreateValidationConstraint(executionEntity)); } } return(formField); }
public virtual FormField createFormField(ExecutionEntity executionEntity) { FormFieldImpl formField = new FormFieldImpl(); // set id formField.Id = id; // set label (evaluate expression) VariableScope variableScope = executionEntity != null ? executionEntity : StartProcessVariableScope.SharedInstance; if (label != null) { object labelValueObject = label.getValue(variableScope); if (labelValueObject != null) { formField.Label = labelValueObject.ToString(); } } formField.BusinessKey = businessKey; // set type formField.Type = type; // set default value (evaluate expression) object defaultValue = null; if (defaultValueExpression != null) { defaultValue = defaultValueExpression.getValue(variableScope); if (defaultValue != null) { formField.DefaultValue = type.convertFormValueToModelValue(defaultValue); } else { formField.DefaultValue = null; } } // value TypedValue value = variableScope.getVariableTyped(id); if (value != null) { formField.Value = type.convertToFormValue(value); } else { // first, need to convert to model value since the default value may be a String Constant specified in the model xml. TypedValue typedDefaultValue = type.convertToModelValue(Variables.untypedValue(defaultValue)); // now convert to form value formField.Value = type.convertToFormValue(typedDefaultValue); } // properties formField.Properties = properties; // validation IList <FormFieldValidationConstraint> validationConstraints = formField.ValidationConstraints; foreach (FormFieldValidationConstraintHandler validationHandler in validationHandlers) { // do not add custom validators if (!"validator".Equals(validationHandler.name)) { validationConstraints.Add(validationHandler.createValidationConstraint(executionEntity)); } } return(formField); }