Hi,
we migrate from a old jBPM3-Engine to Camunda (7.17 with WildFly 26).
Actually we load a Task-Form (index.html and a ExtJS all-classes.js) and evaluates Variables for example “#{myVar}”. In jBPM it resolves it as an empty String when there is no Variable or Function-Mapper found.
In Camunda we did this:
ExpressionManager expressionManager = new ExpressionManager();
ELContext elContext = expressionManager.getElContext(new StartProcessVariableScope());
Object value = expressionManager.createValueExpression(new String(resource.getBytes())).getValue(elContext);
content = value.toString().getBytes();
But every variable throws a PropertyNotFoundException.
Can we prevent this and replace an empty String instead?
How we add Function-Mapper for specific variables like “#{function_abc}”?
Thanks for help.
Hello my friend!!!
I believe you have to change this behavior by creating a class and implementing an ELresolver
interface.
create this class and write it down as Spring Bean and use the getValue
method to return to empty string when the variable is not found.
…and to add a function mapper you can create a class that implements “FunctionMapper
” and extends “ExpressionFactory
”. So you can use the method of ELContextImpl
setFunctionMapper
.
If I helped you in some way, please leave your “like” and mark as “solved” hahahaha: D
Regards.
William Robert Alves
Hi William,
thanks for your answer. I will try it and give you feedback.
Is it a problem when we don´t use spring, rather a Stateless-Bean?
I can´t find a point to do that. ExpressionManager.createElResolver is protected and there is no add-Function.
Another good place is the method “CamundaEngine.getElResolver()”, but it is not called.
Regards.
Martin
hello dude! \o
There is no problem if you are not using spring… the “concept” of using ELResolver
and adding the functionMappers remains the same.
I quoted Spring in the example because that’s what I’m used to using
As for your mentioned problem…
Creating a class extending “ExpressionFactoryImpl
” and overriding the ELResolver createELResolver
method, wouldn’t that solve it?
I hope this helps.
Have a nice day!
Regards.
William Robert Alves
Sorry but there is no method createELResolver
in ExpressionFactoryImpl
.
And where can i set the Resolver or Factory?
I apologize a lot… I got confused with the classes, I’m a little full of tasks at my job right now …
I believe you should create a class that extends from ELResolver
and work with it.
Perhaps a review of this documentation can help you better.
https://www.javadoc.io/static/org.glassfish/javax.el/3.0.0/javax/el/ELResolver.html
Anyway, in case this doesn’t help you… as soon as I have more time, I can try to help you with this.
Regards.
William Robert Alves
Hi William, i have no idea to set another resolver or expressionFactory/Manager.