cancel
Showing results for 
Search instead for 
Did you mean: 

Custom form Type error - unknown type 'textarea'

bbarani
Champ in-the-making
Champ in-the-making
Hi,

I created a custom form type and added the class to the applicationcontext.xml file but for some reason I am getting the below error.

Please find  below my implementation details (reference: book-form example).


Implementing a custom text area form field UI using Vaadin


public class TextAreaFormPropertyRenderer extends AbstractFormPropertyRenderer {

  public TextAreaFormPropertyRenderer() {
    super(TextAreaFormType.class);
  }

  @Override
  public Field getPropertyField(FormProperty formProperty) {
    TextArea textArea = new TextArea(getPropertyLabel(formProperty));
    textArea.setRequired(formProperty.isRequired());
    textArea.setEnabled(formProperty.isWritable());
    textArea.setRows(10);
    textArea.setColumns(50);
    textArea.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));

    if (formProperty.getValue() != null) {
       textArea.setValue(formProperty.getValue());
    }

    return textArea;
  }

}


Implementing a custom text area form type

public class TextAreaFormType extends AbstractFormType {

  public static final String TYPE_NAME = "textarea";
 
  public String getName() {
    return TYPE_NAME;
  }

  @Override
  public Object convertFormValueToModelValue(String propertyValue) {
    return propertyValue;
  }

  @Override
  public String convertModelValueToFormValue(Object modelValue) {
    return (String) modelValue;
  }
}

activiti-standalone-context.xml:

    <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
       <property name="dataSource" ref="dataSource" />
       <property name="transactionManager" ref="transactionManager" />
       <property name="databaseSchemaUpdate" value="true" />
       <property name="jobExecutorActivate" value="true" />
      <property name="customFormTypes">
        <list>
          <ref bean="userFormType"/>
          <ref bean="textAreaFormType"/>
        </list>
      </property>

    <!–  Custom form types –>
    <bean id="userFormType" class="org.activiti.explorer.form.UserFormType"/>
  <bean id="textAreaFormType" class="org.bpmnwithactiviti.explorer.form.TextAreaFormType"/>
  </bean>

activiti-ui-context.xml
 
<property name="propertyRenderers">
      <list>
        <bean class="org.activiti.explorer.ui.form.StringFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.EnumFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.LongFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.DateFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.UserFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.BooleanFormPropertyRenderer" />
        <bean class="org.bpmnwithactiviti.explorer.form.TextAreaFormPropertyRenderer" />
      </list>
    </property>


Error:

SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: unknown type 'textarea' | Latest BPMN.bpm
n20.xml | line 45 | column 82

        at org.activiti.engine.impl.util.xml.Parse.throwActivitiExceptionForErro
rs(Parse.java:186)
        at org.activiti.engine.impl.bpmn.parser.BpmnParse.execute(BpmnParse.java
:242)
        at org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeploy
er.java:92)
        at org.activiti.engine.impl.persistence.deploy.DeploymentCache.deploy(De
ploymentCache.java:38)
        at org.activiti.engine.impl.persistence.entity.DeploymentManager.insertD
eployment(DeploymentManager.java:44)
        at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:61)
        at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:33)
        at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(Comm
andExecutorImpl.java:24)
        at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execut
e(CommandContextInterceptor.java:60)
        at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterc
eptor.java:32)
        at org.activiti.engine.impl.RepositoryServiceImpl.deploy(RepositoryServi
ceImpl.java:68

Can someone let me know what I am doing wrong?

Thanks,
Barani
15 REPLIES 15

frederikherema1
Star Contributor
Star Contributor
How does your BPMN xml look like?

bbarani
Champ in-the-making
Champ in-the-making
How does your BPMN xml look like?

Hi,

Please find below my BPMN XML….I have the form-property id - instructions of type 'textarea'…. but this throws the error..


<process id="CustomFormType" name="Testing Approval process">
  <startEvent id="theStart" activiti:initiator="initiator" />
  <sequenceFlow id="flow1" sourceRef="theStart" targetRef="needsApprovalTask" />
  <serviceTask id="needsApprovalTask" name="Needs approval"
   activiti:class="com.picturerequest.NeedsApprovalDelegate" />

  <sequenceFlow id="flow2" sourceRef="needsApprovalTask"
   targetRef="gateway" />

  <exclusiveGateway id="gateway" name="Needs approval?" />

  <sequenceFlow id="flow3" sourceRef="gateway" targetRef="confirmApproval">
   <conditionExpression xsi:type="tFormalExpression">
    ${needsApproval}
   </conditionExpression>
  </sequenceFlow>

  <sequenceFlow id="flow4" sourceRef="gateway" targetRef="Email">
   <conditionExpression xsi:type="tFormalExpression">
    ${!needsApproval}
   </conditionExpression>
  </sequenceFlow>

  <userTask id="confirmApproval" name="Approve the picture request"
   activiti:candidateUsers="${user}" activiti:assignee="${user}">
   <extensionElements>

    <activiti:formProperty id="initiator" name="Initiator:"
     readable="true" type="string" />

    <activiti:formProperty id="description" name="Description:"
     readable="true" type="string" />

    <activiti:formProperty id="user" name="User:"
     readable="true" type="string" />

    <activiti:formProperty id="imageName" name="Image:"
     readable="true" type="string" />

    <activiti:formProperty id="instructions" name="Instructions"
     type="textarea" />

    <activiti:formProperty id="approvalConfirmed"
     name="approvalConfirmed" type="enum" required="true">
     <activiti:value id="true" name="Yes"></activiti:value>
     <activiti:value id="false" name="No"></activiti:value>
    </activiti:formProperty>
   </extensionElements>
  </userTask>


  <sequenceFlow id="flow5" sourceRef="confirmApproval"
   targetRef="gateway2" />

  <exclusiveGateway id="gateway2" name="Is approval confirmed?" />

  <sequenceFlow id="flow6" sourceRef="gateway2" targetRef="chargeAccount">
   <conditionExpression xsi:type="tFormalExpression"><![CDATA[${approvalConfirmed == 'true'}]]></conditionExpression>
  </sequenceFlow>

  <sequenceFlow id="flow7" sourceRef="gateway2" targetRef="ArchiveTask">
   <conditionExpression xsi:type="tFormalExpression"><![CDATA[${approvalConfirmed == 'false'}]]></conditionExpression>
  </sequenceFlow>



  <serviceTask id="Email" name="Email Service"
   activiti:class="com.picturerequest.ChargeDelegate">
   <extensionElements>
    <activiti:field name="wsdl"
     expression="http://localhost:8521/mailService?wsdl" />
    <activiti:field name="operation" expression="chargeAccount" />
    <activiti:field name="parameters" expression="${user}, ${imageName}" />
    <activiti:field name="returnValue" expression="myReturn" />
   </extensionElements>
  </serviceTask>



  <serviceTask id="chargeAccount" name="Charge account"
   activiti:class="com.picturerequest.ChargeDelegate">
   <extensionElements>
    <activiti:field name="wsdl"
     expression="http://localhost:8291/chargeService?wsdl" />
    <activiti:field name="operation" expression="chargeAccount" />
    <activiti:field name="parameters" expression="${user}, ${imageName}" />
    <activiti:field name="returnValue" expression="myReturn" />
   </extensionElements>
  </serviceTask>

  <sequenceFlow id="flow10" sourceRef="chargeAccount"
   targetRef="ArchiveTask" />

  <sequenceFlow id="flow13" sourceRef="Email" targetRef="theEnd" />

  <serviceTask id="ArchiveTask" name="serviceTask"
   activiti:class="com.picturerequest.ArchiveTask">
  </serviceTask>


  <sequenceFlow id="flow8" sourceRef="ArchiveTask"
   targetRef="theEnd" />

  <endEvent id="theEnd" />

</proc
ess>
</definitions>

frederikherema1
Star Contributor
Star Contributor
That's strange. And you get this error when deploying through the Explorer UI?

bbarani
Champ in-the-making
Champ in-the-making
That's strange. And you get this error when deploying through the Explorer UI?

Yes..I have placed the custom type class(jar) under lib folder of both activiti-rest and activiti-explorer folder but even then I am getting this error whenever I try to deploy using explorer ui..

frederikherema1
Star Contributor
Star Contributor
Is there a way you can debug the explorer application in the class ProcessEngineConfigurationImpl:1021


protected void initFormTypes() {
    if (formTypes==null) {
      formTypes = new FormTypes();
      formTypes.addFormType(new StringFormType());
      formTypes.addFormType(new LongFormType());
      formTypes.addFormType(new DateFormType("dd/MM/yyyy"));
      formTypes.addFormType(new BooleanFormType());
    }
    if (customFormTypes!=null) {
      for (AbstractFormType customFormType: customFormTypes) {
        formTypes.addFormType(customFormType);
      }
    }
  }

End perhaps also, if you see your custom properties being added, on line 1327:


public FormTypes getFormTypes() {
    return formTypes;
  }

javedafroz
Champ in-the-making
Champ in-the-making
I am also facing same issue and I have checked in activiti 5.12 and 5.11. I hav eto show a demo to a potential client and I am stuck  :x . Plzz help..


Thanks in advance.

jbarrez
Star Contributor
Star Contributor
I've recently written down the steps I needed to do to get it working: http://www.jorambarrez.be/blog/2013/03/13/creating-a-new-form-property-in-activiti/

Hope that you can find the differences with your environment there.

javedafroz
Champ in-the-making
Champ in-the-making
I have already tried all those steps. The problem is that system is not even recognizing the pre-existing custom types - user and processDefinition. It is always throwing same errors for them - "unknown type "user" approver". I don't know where am I getting it wrong. Following is the code I am using for generating text area.

TextAreaFormType.java

package org.activiti.explorer.form;

import org.activiti.engine.impl.form.AbstractFormType;



public class TextAreaFormType extends AbstractFormType {

public static final String TYPE_NAME = "textarea";

public String getName() {
  return TYPE_NAME;
}

@Override
public Object convertFormValueToModelValue(String propertyValue) {
  return propertyValue;
}

@Override
public String convertModelValueToFormValue(Object modelValue) {
  return (String) modelValue;
}
}

TextAreaFormPropertyRenderer.java

package org.activiti.explorer.ui.form;

import org.activiti.engine.form.FormProperty;
import org.activiti.explorer.Messages;
import org.activiti.explorer.form.TextAreaFormType;
import org.activiti.explorer.ui.form.AbstractFormPropertyRenderer;

import com.vaadin.ui.Field;
import com.vaadin.ui.TextArea;

public class TextAreaFormPropertyRenderer extends AbstractFormPropertyRenderer {

public TextAreaFormPropertyRenderer() {
  super(TextAreaFormType.class);
}

@Override
public Field getPropertyField(FormProperty formProperty) {
  TextArea textArea = new TextArea(getPropertyLabel(formProperty));
  textArea.setRequired(formProperty.isRequired());
  textArea.setEnabled(formProperty.isWritable());
  textArea.setRows(10);
  textArea.setColumns(50);
  textArea.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED,
    getPropertyLabel(formProperty)));

  if (formProperty.getValue() != null) {
   textArea.setValue(formProperty.getValue());
  }

  return textArea;
}

}

activiti-standalone-context.xml

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
   <property name="dataSource" ref="dataSource" />
   <property name="transactionManager" ref="transactionManager" />
   <property name="databaseSchemaUpdate" value="true" />
   <property name="jobExecutorActivate" value="true" />
    <property name="customFormTypes">
      <list>
        <bean class="org.activiti.explorer.form.UserFormType"/>
  <bean class="org.activiti.explorer.form.TextAreaFormType"/>
      </list>
    </property>
  </bean>

activiti-ui-context.xml

<bean id="formPropertyRendererManager" class="org.activiti.explorer.ui.form.FormPropertyRendererManager" lazy-init="true">
    <!– Default renderer –>
    <property name="noTypePropertyRenderer">
      <bean class="org.activiti.explorer.ui.form.StringFormPropertyRenderer" />
    </property>
    <!– Renderers by property type –>
    <property name="propertyRenderers">
      <list>
        <bean class="org.activiti.explorer.ui.form.StringFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.EnumFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.LongFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.DateFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.UserFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.BooleanFormPropertyRenderer" />
<bean class="org.activiti.explorer.ui.form.TextAreaFormPropertyRenderer" />
      </list>
    </property>
  </bean>

Please help.

frederikherema1
Star Contributor
Star Contributor
How are you actually modifying and deploying the explorer-app?