cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Rest Response for custom form properties extending EnumFormType

tap007
Champ in-the-making
Champ in-the-making
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.
8 REPLIES 8

jbarrez
Star Contributor
Star Contributor
Hmm not sure what you are trying to do here, could you explain with a simple example?

tap007
Champ in-the-making
Champ in-the-making
I have created a new form type SelectBoxForomType (attached in the question SelectBoxForomType.txt ). This form type extends EnumFormType and I am putting my values as form values using eclipse plugin. When I request for form properties using rest call, I do not get form values I provided in enumValues, it is blank instead as below:
,"formProperties":[{"id":"DelegateList","name":"Delegate","type":"selectBox","value":null,"readable":true,"writable":true,"required":true,"datePattern":null,"enumValues":[]}]

If I were using EnumFormType, I would have got the form values in enumValues when I request form properties using rest call http://localhost/wfc/service/form/form-data?taskId=55. But for my custom form type enumvalues are not returned.

How do I make sure I get the form values in the enumValues in rest response in my custom form type.

trademak
Star Contributor
Star Contributor
Did you register the SelexBoxFormType as a form property type in the Engine configuration?

Best regards,

tap007
Champ in-the-making
Champ in-the-making
yes I have registered it. I am starting process engine programatically. Below is the snippet from Java code.

       protected synchronized ProcessEngine initializeProcessEngine() {
  if(engine == null){
   log.debug("Starting Activiti Process Engine");
   ProcessEngineConfigurationImpl processEngine =  (ProcessEngineConfigurationImpl)     ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
   processEngine.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
   processEngine.setDataSource(Database.getDataSource(params));

   // Configure the Custom Forms
   processEngine.setCustomFormTypes(createCustomFormList());
   // Set the beans to engine.
   processEngine.setBeans(createBeansMap());
   // Activate the Job executor.
   processEngine.setJobExecutorActivate(true);
   // Enable database event logging.
   processEngine.setEnableDatabaseEventLogging(true);
   // engine should be assigned here itself to support null check and synchronized block
   engine = processEngine.buildProcessEngine();

  }else{
   log.debug("Activiti Process Engine is already started, ignoring this attempt to start");
  }
  return engine;
}

private List<AbstractFormType> createCustomFormList() {
  List<AbstractFormType> customFormList = new ArrayList<AbstractFormType>();
  customFormList.add(new UserFormType());
  customFormList.add(new ProcessDefinitionFormType());
  customFormList.add(new MonthFormType());
  // Custom form type
  customFormList.add(new LabelFormType());
  customFormList.add(new HeadingFormType());
  customFormList.add(new TextAreaFormType());
  customFormList.add(new RadioButtonFormType());
  customFormList.add(new SelectBoxFormType());
  customFormList.add(new FormButtonFormType());
  customFormList.add(new AppenderFormType());
  return customFormList;
}

trademak
Star Contributor
Star Contributor
When we would change the logic and lookup the type value in the Engine form types and see if the class extends from EnumFormType that would be possible I think. Would you be willing to create a pull request for this?

Best regards,

himani
Champ in-the-making
Champ in-the-making
Hi Tjis,

Is this feature now available ? Can we now use the form values provided using eclipse plugin in custom form types.

Thanks
Himani

trademak
Star Contributor
Star Contributor
Hi Himani,

Which feature are you referring to? The Eclipse Designer hasn't been changed for custom form types yet.

Best regards,

himani
Champ in-the-making
Champ in-the-making
Hi Tjis,

I mean the check in code which does a string comparison of Form Type as EnumFormType and only then reads form values. Due to this there is no way to read form values for Custom Form type created.

Comment from above :
"If I were using EnumFormType, I would have got the form values in enumValues when I request form properties using rest call http://localhost/wfc/service/form/form-data?taskId=55. But for my custom form type enumvalues are not returned."

Thanks
Himani