AnsweredAssumed Answered

Rest API Get form data forn new type option-group

Question asked by butik on Sep 8, 2014
Latest reply on Sep 8, 2014 by trademak
Hello,

I have added new form type option-gorup, it is very simmilar to enum, but displays group of options instead of select.
It is correctly rendered for Activiti Explorer, but for rest api I didn't received enum values for this new type.
I figured out that I have to override createFormDataResponse method from RestResponseFactory class, since "enum" is hardcoded there, so I have to add "option-group" also:

if ("enum".equals(restFormProp.getType()) || "option-group".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);
            }
          }
        }


Would it be better to remove if condition if ("enum".equals(restFormProp.getType())) from core code?
In that case user will not need to extend RestResponseFactory  and override createFormDataResponse .

BR,
Paul

Outcomes