AnsweredAssumed Answered

Cannot set value of a non-lvalue expression

Question asked by martin.p on Dec 3, 2013
Latest reply on Dec 4, 2013 by martin.p
Hi,

My process has custom widgets associated with formProperties. One of these properties may or not be defined, according to an external condition. My main goal is to be able to pass an information to the FormRenderer so that it is able to decide by itself if it should display or not.

I implemented this as follow, and it worked at the beginning, but now I got this weird exception :

Caused by: org.activiti.engine.impl.javax.el.ELException: Cannot set value of a non-lvalue expression 'execution.getVariable('flightEventId')'
at org.activiti.engine.impl.juel.AstMethod.setValue(AstMethod.java:48)
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)
… 64 more

Can someone help me understanding this error, or indicate a better way to implement conditional forms?
I am using Activiti 5.10

Process task:

      <userTask id="validate" name="Valider" activiti:candidateGroups="${execution.getVariable(&quot;guarantor&quot;)}">
        <extensionElements>
           …
          <activiti:formProperty id="is-responsible" name="responsability" type="is-responsible" expression="${execution.getVariable(&quot;flightEventId&quot;)}"></activiti:formProperty>
           …
      </extensionElements>
      </userTask>


The "is-responsible" form type let us have a IsResponsibleFormPropertyRenderer:


public class IsResponsibleFormPropertyRenderer extends AbstractFormPropertyRenderer {
    public IsResponsibleFormPropertyRenderer() {
        super(IsResponsibleFormType.class);
    }

    @Override
    public Field getPropertyField(FormProperty formProperty) {
        boolean visible = isCategoryAssignableForResponsability(formProperty);
        OptionGroup og = buildOptionGroup(visible);
        return og;
    }

    private boolean isCategoryAssignableForResponsability(FormProperty formProperty) {
        String eventFlightId = formProperty.getValue();
        if (eventFlightId != null) {
            FlightEventService flightEventService = ExplorerApp.get().getFlightEventService();
            return getFlightEventCategoryAssignability(eventFlightId, flightEventService);
        }
        else{
            return false;           
        }
    }

    private boolean getFlightEventCategoryAssignability(String eventFlightId, FlightEventService flightEventService) {
       … // doing complex things
    }
    …
}


To summarize, I need to provide a variable to the form that will be used to retrieve informations that let me decide how to render the widget.

Many thanks in advance for your help.

Outcomes