AnsweredAssumed Answered

Adding configuration information to a FormProperty

Question asked by joaquinb on Sep 17, 2013
Latest reply on Sep 20, 2013 by frederikheremans1
I need to render (with ZK) a UserTask in an application reading collection of formPropertys.

I don't know if it's possible to create a new data type and adding configurations to an instance in a form of this datatype.

For example, starting at sample TextAreaFormType i need to configure number of rows and number of columns to show when render this type of data.

I think that only extend the class org.activiti.engine.impl.form.FormTypes and overriding function
public AbstractFormType parseFormPropertyType(FormProperty formProperty) .

I implemented this solution but I think it's very bad. I don't know how to add form attributes  with configuration because
needs to change FormProperty to read variable attributes from xml.
For example:

<activiti:formProperty id="tipoAreaTexto" name="Tipo area texto" type="textarea" variable="tipoAreaTexto" required="true"  rows="5">

Instead I added this solution using activiti:value tag xml:
       <activiti:formProperty id="tipoAreaTexto" name="Tipo area texto" type="textarea" variable="tipoAreaTexto" required="true">
          <activiti:value id="rows" name="10"></activiti:value>

1. Create a new class FormTypesExtended

import org.activiti.bpmn.model.FormProperty;
import org.activiti.bpmn.model.FormValue;
import org.activiti.engine.form.AbstractFormType;
import org.activiti.engine.impl.form.BooleanFormType;
import org.activiti.engine.impl.form.DateFormType;
import org.activiti.engine.impl.form.FormTypes;
import org.activiti.engine.impl.form.LongFormType;
import org.activiti.engine.impl.form.StringFormType;

public class FormTypesExtended extends FormTypes {

   public FormTypesExtended() {
      super.addFormType(new StringFormType());
      super.addFormType(new LongFormType());
      super.addFormType(new DateFormType("dd/MM/yyyy"));
      super.addFormType(new BooleanFormType());

   public AbstractFormType parseFormPropertyType(FormProperty formProperty) {

      if ("textarea".equals(formProperty.getType())) {

         Map values = new LinkedHashMap();
         Integer rows = new Integer(3);

         // Access formProperty values..
         for (FormValue formValue : formProperty.getFormValues()) {

            // Contains rows
            if ("rows".equals(formValue.getId())) {
               rows = Integer.parseInt(formValue.getName());

         // Create new type with rows..
         TextAreaFormActivitiType textAreaType = new TextAreaFormActivitiType();

         return textAreaType;

      return super.parseFormPropertyType(formProperty);

2. Adding class TextAreaFormActivitiType
public class TextAreaFormActivitiType extends AbstractFormType {

   public static final String TYPE_NAME = "textarea";

   private Integer _rows = new Integer(0);

   public TextAreaFormActivitiType() {

   public Integer getRows() {
      return this._rows;

   public void setRows(Integer rows) {
      this._rows = rows;

3. adding configuration in spring-activiti.xml
  <bean id="formTypesExtended" class="com.inditex.tempe.activiti.types.FormTypesExtended">

  <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
    <property name="formTypes" ref="formTypesExtended" />