To display the forms, we make rest call and display the form elements on a JSP by looping on the form properties. The HTML elements are generated depending on the type of the form property. We have created custom form type for select drop down. Attaching the java file. This form type extends EnumFormType.
This custom form type does not return the values entered in enumvalues field of json data received on rest call. When we looked up the source code, we found that org.activiti.rest.service.api.RestResponseFactory.createFormDataResponse(SecuredResource, FormData) has a string compare for enum type:
if ("enum".equals(restFormProp.getType())) {
Object values = formProp.getType().getInformation("values");
if (values != null) {
@SuppressWarnings("unchecked")
Map<String, String> enumValues = (Map<String, String>) values;
for (String enumId : enumValues.keySet()) {
RestEnumFormProperty enumProperty = new RestEnumFormProperty();
enumProperty.setId(enumId);
enumProperty.setName(enumValues.get(enumId));
restFormProp.addEnumValue(enumProperty);
}
}
}
I was wondering if instead of comparing the strings if we can have instance of check then any class extending EnumFormType will be able to get values in the rest response json. Any specific reason for keeping it a String compare.