cancel
Showing results for 
Search instead for 
Did you mean: 

Form variable types

tbe
Champ in-the-making
Champ in-the-making
Hi,

I have a question regarding the form variable types:

I use the built in FormRenderer to render the forms and to display them inside our app. When submitted, I use submitStartFormData to start a new instance. I also pass the _type fields of the form.

The method only accepts Map<String, String> for the form data and stores every variable as a string in the instance, independend of the _type arguments. E.g. when I use the "Handle vacation request" example, it's not able to evaluate the expression ${approved} because of its type.

Is there any way to pass booleans and other type or to let the form engine convert them?

Best regards,
Tom
7 REPLIES 7

tombaeyens
Champ in-the-making
Champ in-the-making
The type conversion is not based on the type_ properties that you submit.

The type conversion is specified in the process.

http://www.activiti.org/userguide/index.html#formProperties

tbe
Champ in-the-making
Champ in-the-making
Hi,

I tried this also, but the manual doesn't list "boolean" as a supported type. I didn't find a way yet to create a boolean yes/no property in my form and to check it with a simple boolean expression (like ${approved}) in an exclusion gateway (but the vacation request example does it, even without form properties?).

Tom

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
If it is not in the docs and it does not work, it most likely is not implemented (yet)

jbarrez
Star Contributor
Star Contributor
This is the example that is shipped in the distribution:


<select name="vacationApproved">
    <option value="true">Yes</option>
    <option value="false">No</option>
</select>
<input type="hidden" name="vacationApproved_type" value="Boolean" />

tbe
Champ in-the-making
Champ in-the-making
Hi,

that's the example I used. But we use our own frontend instead of the activiti webapps. After the user commits a form, we use the FormService submit method (which only accepts a <String,String> map).

I still didn't get how to tell the system that "vacationApproved" is a boolean, because the _type args are unimportant and the form properties don't allow to declare a variable as boolean.

Best regards,
Tom

mproch
Champ in-the-making
Champ in-the-making
I think that activiti explorer (and REST API) is using RuntimeService.startProcessInstanceById and TaskService.complete methods, which accept Map<String, Object> as parameters. The conversion from parameters passed to REST API (which include _type properties currently) is done in activiti-webapp-rest.
So I think you can just use these methods and pass Boolean object as value in map. However, looking at source code it seems that these method do not insert some history date, as FormService does.

Don't know when (and why) you should use FormService and when TaskService however…

frederikherema1
Star Contributor
Star Contributor
The form-properties were introduced to offer a more integrated approach on describing forms. With the properties, you can define the types etc. of the fields on the form, making it possible to have UI's create forms based on those values instead of using form-rendering.

Also, formproperties don't have to map one-to-one on variables. You can fill in a field on a form and have it be stored as another variable or have form-properties depend on other existing variables. When just completing a task using the taskService, ALL variables passed will be saved on the execution, and you have no real no fine-grained IN/OUT contol.

The form-properties typing mechanism is pluggable, so you can add custom form-types and supply your own string-object and visa-versa conversion, inside the engine. This way, all clients (rest, API) can just use Strings and conversion is done in the engine itself.

You can offcourse just use taskService.completeTask() and pass variables, using strong-typed map, it's the easiest way to do this when you're invoking it using Java API.

More on the form properties can be found in the userguide: http://activiti.org/userguide/index.html#formProperties