cancel
Showing results for 
Search instead for 
Did you mean: 

How to get get enum values from FormProperties

tschiela
Champ in-the-making
Champ in-the-making
Hello again,

i designed a simple usertask-workflow with Activiti Desinger. The user task contains a form, which contains a enum type. The set 3 values to the enum type. The Activiti Explorer shows a combobox with 3 values, all correct. But how i can get these 3 values throw the Java Api?

The probleme here is that i only can get a String from my enum field. But there must be something like a HashMap with the values.

if("enum".equals(p.getType().getName())){               
   logger.info(p.getValue());               
}


Greets
Thomas
4 REPLIES 4

frederikherema1
Star Contributor
Star Contributor
From source of Explorer UI component, responsible for rendering those values (org.activiti.explorer.ui.form.EnumFormPropertyRenderer):


Map<String, String> values = (Map<String, String>) formProperty.getType().getInformation("values");
    if (values != null) {
      for (Entry<String, String> enumEntry : values.entrySet()) {
        // Add value and label (if any)
        comboBox.addItem(enumEntry.getKey());
        if (enumEntry.getValue() != null) {
          comboBox.setItemCaption(enumEntry.getKey(), enumEntry.getValue());
        }
      }
    }

I really suggest looking into the source-code, if you're looking for API calls that go with explorer-ui behavior…

tschiela
Champ in-the-making
Champ in-the-making
thank you  Smiley Happy

// edit:
do you know a reason why FormService.getRenderedTaskForm(taskId) return null?

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
New questions in new topics please. And please use the userforum

javaj3d1
Champ in-the-making
Champ in-the-making
The code above doesn't work with custom form properties.

I followed this tutorial:

http://www.jorambarrez.be/blog/2013/03/13/creating-a-new-form-property-in-activiti/

I created a custom form property, and when invoking Map<String, String> values = (Map<String, String>) formProperty.getType().getInformation("values"); that always returns null.

I noticed that by default AbstractFormType.getInformation always return null but even after overriding the getInformation method it is still returning null when I use the code given by frederikheremans.

Any ideas?