cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Form Type

pedwards
Champ on-the-rise
Champ on-the-rise
Hi Guys,

I'm hoping someone can quickly tell me what I'm doing wrong. I have activiti 5.12.1 running happily. I have created a simple flow with some custom forms and its all happy.

However I know I am going to need more complicated formtypes than the supplied, so as a simple test, I decided to create a "integer" form type. So I created the simple classes:

public class IntegerFormPropertyRenderer extends AbstractFormPropertyRenderer
public class IntegerValidator extends AbstractStringValidator
public class IntegerFormType extends AbstractFormType


I compiled these into a jar, and wacked them into activiti-explorer/WEB-INF/lib. I then modified activiti-ui-context.xml to have:

  <bean id="formPropertyRendererManager" class="org.activiti.explorer.ui.form.FormPropertyRendererManager">
    <!– 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.ProcessDefinitionFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.MonthFormPropertyRenderer" />
        <bean class="org.xxx.xxx.formtypes.IntegerFormPropertyRenderer" />
      </list>
    </property>
  </bean>


Then I restarted everything, and tried to upload a workflow that uses this as a form component. No dice, it blows with:
org.activiti.engine.ActivitiIllegalArgumentException: unknown type 'integer' amount
   at org.activiti.engine.impl.form.FormTypes.parseFormPropertyType(FormTypes.java:55)

Which tells me that my form type never made it into FormTypes. So I attached the debugger, I can see that FormTypes is populated by default, before the explorer app is ever started. However when I do access the webapp, I can see the FormPropertyRendererManager is indeed populated with my extra class, however I don't see it ever get loaded into FormTypes.

So my question is, how do propertyRenderers get added to FormTypes? Cause at the moment it appears to me that they are ignored.

Thanks
Paul.
6 REPLIES 6

pedwards
Champ on-the-rise
Champ on-the-rise
Oh, just to be clear:

<code>
package org.xxx.xxx.formtypes;

import org.activiti.engine.form.AbstractFormType;

public class IntegerFormType extends AbstractFormType {

    public static final String TYPE_NAME = "integer";

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

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

    @Override
    public String getName() {
        return TYPE_NAME;
    }
}
</code>

pedwards
Champ on-the-rise
Champ on-the-rise
Just found this: http://www.jorambarrez.be/blog/2013/03/13/creating-a-new-form-property-in-activiti/
Seems that whatever I was reading was wrong… let me try that again

pedwards
Champ on-the-rise
Champ on-the-rise
Yip that was all it was, I was missing:

<code>
<bean id="processEngineConfiguration" … >
  …
  <property name="customFormTypes">
    <list>
      …
      <bean class="org.activiti.explorer.form.MonthFormType"/>
    </list>
  </property>
</bean>
</code>

jbarrez
Star Contributor
Star Contributor
Now that was a nice monologue 😉

But thanks for posting back!

thebruuu
Champ in-the-making
Champ in-the-making
Hi pedwards

Could you post the full eclipse project ?  the community would appreciate for sure!
Thanks

slaimankoeik
Champ in-the-making
Champ in-the-making
Hello,
1-I have same scenario for Pedwards but the thing i didn't understand is that how i will load to the activiti explorer my custom form property ?
how ?
i tried to insert this code into my eclipse process engine configuration file but the activiti explorer isn't identifying it:

<code>
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
<property name="databaseSchemaUpdate" value="true" />
     <property name="customFormTypes">
      <list>
      <bean id="enumformtype" class="log_stream.enumformtype"/>
      </list>
     </property>
    </bean>
</code>

2-that what i understod from this link  http://www.jorambarrez.be/blog/2013/03/13/creating-a-new-form-property-in-activiti/, but i didn't understand how inserting the custom form type into the eclipse configuraton file will notify activiti explorer for identifying this custom form type ???

please anyone has an idea.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.