cancel
Showing results for 
Search instead for 
Did you mean: 

How to map Vaadin tables to form properties?

andregs
Champ in-the-making
Champ in-the-making
Hi,

I'm building an user form using Vaadin as explained here: http://vaadin.com/wiki/-/wiki/Main/Building%20Vaadin%20Applications%20on%20top%20of%20Activiti

My form has some text fields and also a Vaadin editable Table. The user clicks on a "new item" button to create new items (aka rows) in the table. When the user submits the form, I want to map the submited form data (including the table items) to activiti form properties. I already have one <activiti:formProperty /> for each field in my form, but I don't know how to map the table items.

Must I have one activiti:formProperty for the entire table? If so, how can I convert the entire table data to the Map<String, String> required by FormService.submitStartFormData()?

Thanks for your help,
6 REPLIES 6

frederikherema1
Star Contributor
Star Contributor
As a matter of fact, activiti-webapp-explorer2 has this mechanism built in, and is vaadin. The default form-type (string, date, boolean, …) are rendered as widgets on a form, which exposes Map<String, String> which can be used to submit as properties. This form also does the required-validation. On top of that, it allows you to plug in rendering for custom form-property types.

@see http://svn.codehaus.org/activiti/activiti/trunk/modules/activiti-webapp-explorer2/src/main/java/org/...

@see org.activiti.explorer.ui.form.FormPropertiesForm
@see org.activiti.explorer.ui.form.FormPropertyRenderer

andregs
Champ in-the-making
Champ in-the-making
I'm glad Explorer2 will be Vaadin based. Unfortunately, I still don't understand how to map the table to form property… I'm newbie and learning a bit more every day.

I think I have two options here:
1. serialize the whole table data in a string, and submit this string as a regular form property.
2. create a customFormType, as in here: http://forums.activiti.org/en/viewtopic.php?f=6&t=1401

I think the second one is the best way, but I don't know how to create such formType… Could you help me here? It's easy to extend the AbstractFormType, but I don't know how to use my custom class.

Maybe is there another way of doing this?

Thanks for your time,

andregs
Champ in-the-making
Champ in-the-making
Please, do you need more information about my questions?

Thanks,

frederikherema1
Star Contributor
Star Contributor
The way to go is to extend the AbstractFormType, and add the class to the configuration of you engine, like this:

<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"/>
          </list>
        </property>
  </bean>

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

anshuman
Champ in-the-making
Champ in-the-making
Hi andregs,
Just want to know if you are able to map the table data to the form properties.Facing the same issue.In my case i received a xml request from the client say for example:
<Errorlist>
<Error>
<errorcode>123</errorcode>
<errordesc>xyz..</errordesc>
</Error>
<Error>
<errorcode>345</errorcode>
<errordesc>abc..</errordesc>
</Error>
<Errorlist>
I want to display the Error contents in the table in activiti explorer.Can you suggest how to proceed with this??

jbarrez
Star Contributor
Star Contributor
I just wrote down on my blog how to create custom form types: see http://www.jorambarrez.be/blog/2013/03/13/creating-a-new-form-property-in-activiti/