Getting Rest Response for custom form properties extending EnumFormType

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2014 07:45 AM
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.
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.
Labels:
- Labels:
-
Archive
8 REPLIES 8
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2014 06:29 PM
Hmm not sure what you are trying to do here, could you explain with a simple example?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2014 05:35 AM
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.
,"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.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2014 10:44 AM
Did you register the SelexBoxFormType as a form property type in the Engine configuration?
Best regards,
Best regards,

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2014 11:15 AM
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;
}
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;
}

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2014 05:26 AM
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,
Best regards,

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2015 05:35 AM
Hi Tjis,
Is this feature now available ? Can we now use the form values provided using eclipse plugin in custom form types.
Thanks
Himani
Is this feature now available ? Can we now use the form values provided using eclipse plugin in custom form types.
Thanks
Himani

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2015 06:30 AM
Hi Himani,
Which feature are you referring to? The Eclipse Designer hasn't been changed for custom form types yet.
Best regards,
Which feature are you referring to? The Eclipse Designer hasn't been changed for custom form types yet.
Best regards,

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2015 01:45 AM
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
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
