cancel
Showing results for 
Search instead for 
Did you mean: 

External form rendering : Form properties values listing

fredg
Champ in-the-making
Champ in-the-making
Hi all,

I’m working on a workaround to migrate from jpdl outgoing transitions to BPMN 2 (human task + Exclusive gateway)

My need:

* Provide a form display; give user a choice to decide next step (outgoing sequence flow).
* Choice must be "by design" embedded in process. (using Activiti Eclipse Designer)

Reading this forum I saw that the way to do is using a process like this: a usertask followed by an exclusive gateway.


My solution:

* UserTask : add some form properties, and use them for the following Exclusive gateway evaluation.
Example:

    <formProperties id="step1" name=" step1" type="enum" value="TaskA,TaskB" readable="true" />
    <formProperties id="step2" name=" step2" type="string" value="TaskA,TaskB" readable="true" />
* List those values using List<FormProperty> formService.getTaskFormData(task.getId()).getFormProperties()

Unfortunately, List<FormProperty> is always empty and I can't get any of them, so I’m unable to provide my user a choice.


I would like to access a form property default value, in my case "TaskA,TaskB"
The user choice (TaskA or TaskB) with then be added to a variable so the gateway can take a decision.

Can someone explain why FormProperty.getValue() is always null ?


Activiti 5.6, postgres 9, spring 3.x

Here is code :


   ProcessInstance processInstance = null;
        try {
            /**
             * You must define "initiator" on StartEvent node
             * FIXME Thead safe ?
             */
            this.identityService.setAuthenticatedUserId("ofred");
            processInstance = this.runtimeService.startProcessInstanceByKey("testGateway",
                            null,
                            new HashMap<String, Object>());
        } finally {
            this.identityService.setAuthenticatedUserId(null);
        }
        assertFalse(processInstance.isEnded());
        //Step 1 : we should wait on usertask1
        Task task = this.taskService.createTaskQuery()
            .processInstanceId(processInstance.getId())
            .singleResult();
        assertEquals("User Task", task.getName());
        //FORM
        Object o = this.formService.getRenderedTaskForm(task.getId());
        assertNull(o);
        /**
         * Get list of available user choice : pseudo out going transitions
         * Process definition must be readable="true"
         * ENUM types not yet supported see http://jira.codehaus.org/browse/ACT-882 as java enum (and sucks in designer)
         */
        StartFormData startformData = this.formService.getStartFormData(processInstance.getProcessDefinitionId());
        assertNotNull(startformData);
        assertEquals(0, startformData.getFormProperties().size());
        /**
         * Only readable="true" will be visible
         */
        TaskFormData formData = this.formService.getTaskFormData(task.getId());
        List<FormProperty> data = formData.getFormProperties();
        assertNotNull(data);
        assertTrue(data.size() > 0);//FIXME fails !!
        for (FormProperty prop : data) {
            String id = prop.getId();
            String value = prop.getValue();
        }
11 REPLIES 11

raymondx
Champ in-the-making
Champ in-the-making
I tried to do same.
I watched how EnumFormType.java is written, and created a type with the same constructor (HashMap<String,String>)

Here is the code:

<java>
public class ClassSemesterType extends AbstractFormType {
//http://forums.activiti.org/content/external-form-rendering-form-properties-values-listing
public static final String TYPE_NAME = "classsemester";

protected Map<String,String> values;


public ClassSemesterType(Map<String, String> values){
 
  this.values = values;
}


@Override
public Object getInformation(String key){
  if(key.equals("values")){
   return values;
  }
 
  return null;
}

/*public ClassSemesterType(){
  this.getInformation(key)
}*/


public Object convertFormValueToModelValue(String propertyValue) {
  return propertyValue.toString();

}

public String convertModelValueToFormValue(Object modelValue) {
  if (modelValue == null) {
   return null;
  }
  return modelValue.toString();
}

public String getName() {
  return TYPE_NAME;
}
</java>


But if I deploy my jar into the tomcat, then activiti thinks:

<code>
aused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [zeus.activiti.type.ClassSemesterType]: No default constructor found; nested exception is java.lang.NoSuchMethodException: zeus.activiti.type.ClassSemesterType.<init>()
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:85)

</code>

But EnumFormType does not have a default constructor, its the same constructor, so what am I doing wrong?

I just want to have access on a property of the last task. As Example in the last task is a property with the name = "anyid", its a String, its readable, writable etc. pp.
Example:
Task 1 -> Choose Something (anyid = String)
Task 2 -> Print the choosed anyid of Task 1 (from the typerenderer)…



Raymond

jbarrez
Star Contributor
Star Contributor
Pass the key/value map into the constructor when you define the bean in xml, then the default constructor is not called.