AnsweredAssumed Answered

Default values for Activiti form properties

Question asked by thilo.ginkel on Dec 9, 2011
Latest reply on Mar 1, 2016 by jbarrez
Hi there,

we are using Activiti's FormService to attach custom form properties to tasks, e.g.:


    <userTask id="usertask1" name="Task 1"" activiti:candidateGroups="Group">
      <extensionElements>
        <activiti:formProperty id="someProperty" name="Some Property" type="boolean" required="true" readable="true" writable="true"></activiti:formProperty>
      </extensionElements>
    </userTask>
What I would like to do, though, is to initialize the property with a default value in case no variable someProperty has been created in the process context so far.

I tried attaching an expression to the property, but this variant does not work as Activity will attempt an assignment to the expression on save, which will obviously fail:


    <userTask id="usertask1" name="Task 1"" activiti:candidateGroups="Group">
      <extensionElements>
        <activiti:formProperty id="someProperty" name="Some Property" type="boolean" required="true" readable="true" writable="true" expression="${false}"></activiti:formProperty>
      </extensionElements>
    </userTask>
org.activiti.engine.impl.javax.el.ELException: Cannot set value of a non-lvalue expression 'false'
   at org.activiti.engine.impl.juel.AstRightValue.setValue(AstRightValue.java:53)
   at org.activiti.engine.impl.juel.AstEval.setValue(AstEval.java:86)
   at org.activiti.engine.impl.juel.TreeValueExpression.setValue(TreeValueExpression.java:138)
   at org.activiti.engine.impl.delegate.ExpressionSetInvocation.invoke(ExpressionSetInvocation.java:37)
   at org.activiti.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:37)
   at org.activiti.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:25)
   at org.activiti.engine.impl.el.JuelExpression.setValue(JuelExpression.java:69)
   … 118 more
Now I thought about adding some kind of default expression that is used to initialize a form property iff the backing variable does not yet exist in the current execution scope.

What are your thoughts about this? If you think that this makes sense I would go ahead and contribute a patch…

Regards,
Thilo

Outcomes