cancel
Showing results for 
Search instead for 
Did you mean: 

Null values handling for submit form

heven
Champ in-the-making
Champ in-the-making
Hello,

I implemented a custom form type for my user task.
During a FormService.submitTaskFormData I want to set this specific property to null, therefore I add the form property id and a null value to the map which is used for the submitTaskFormData call.
My convertFormValueToModelValue method of my AbstractFormType implementation is executed where I return null In case the propertyValue is null but the null value is never set to the variable of my form property.

A look at the FormPropertyHandler.submitFormProperty code shows that the value is only stored to variables or variable expressions when it is not null.

    if (modelValue != null) {
      if (variableName != null) {
        execution.setVariable(variableName, modelValue);
      } else if (variableExpression != null) {
        variableExpression.setValue(modelValue, execution);
      } else {
        execution.setVariable(id, modelValue);
      }
    }


This doesn’t make much sense for me. Why do you prevent null values?
Is there a way to change this behavior without changing the activiti code?
9 REPLIES 9

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
When you look at it from a buisiness (not java) perspective, null is not a very meaningful value. You could as well not set the variable at all (that is what we do).

But maybe If you describe the use case my opinion might change…

heven
Champ in-the-making
Champ in-the-making
It's in fact not a business perspective, but what I am doing is, I have custom form property in recurring user task in a loop.

The user may choose to leave the form property empty. After the user task I cannot see whether the value is from the previous run or the user chose the same value once again or even if he chose to leave the value empty.

jbarrez
Star Contributor
Star Contributor
If the variable doesn't exist, you know the user didn't fill it in.

It feels like you're trying to capture at least three meanings with one 'null value'.
You'll have to add some task listener logic there, to check which 'run' of the task it was, and insert a different variable into the process.

heven
Champ in-the-making
Champ in-the-making
If the variable doesn't exist, you know the user didn't fill it in.
It feels like you're trying to capture at least three meanings with one 'null value' …

But this variable already exists from a previous run in the loop.
I don't think I am mixing up something or maybe I don't got you right.

Here are the cases:

With null value:
User type something in -> value is stored in the variable
User leave it empty -> null is stored in the variable

In this case it is pretty clear what the user input was.

Without null value:
User type something in -> value is stored in the variable
User left it empty -> variable stays untouched and still has the value from the previous run

In this case I cannot see if the user chooses to leave the input empty or add the same value once again

I can probably solve somehow the problem with a listener, or write variables directly during a user task instead of using form properties, but it could be so simple with null values.

jbarrez
Star Contributor
Star Contributor
But if you replace 'null value of variable' with 'variable not stored in process', then you get the same semantics, no?

heven
Champ in-the-making
Champ in-the-making
That's right, but how can I remove the process Variable using submitTaskFormData?

jbarrez
Star Contributor
Star Contributor
Hmm, okay now I see your point a bit. I'm not yet 100% convinced about null values, but could you create a jira for it, so we can discuss it internally?

heven
Champ in-the-making
Champ in-the-making
Hi,

it looks like it is currently no possible to sign up for an Jira account using the link on the community page. Is there an other way?

jbarrez
Star Contributor
Star Contributor
Doesn't registering through http://jira.codehaus.org/browse/ACT work?
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.