cancel
Showing results for 
Search instead for 
Did you mean: 

How to use class full package name in line's condition expr?

tse
Champ in-the-making
Champ in-the-making
I would like to compare a process variable (enum variable) to one of its possible value. It seems that using class full package name is not possible in the condition:


${status==a.b.c.StatusEnum.REJECTED}

throws:

Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'a'
        at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)

Is there any way to do this using condition on sequence flow?

(I use SpringProcessEngineConfiguration if it does matter.)
4 REPLIES 4

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
From using 

https://www.google.nl/search?q=using+enums+in+EL

There were several hits. The first one also helps, but the 4th is the spec and from that:

When referencing an enum constant with an expression, you use a String literal. For example, consider this Enum class:

public enum Suit {hearts, spades, diamonds, clubs}

To refer to the Suit constant, Suit.hearts with an expression, you use the String literal, "hearts". Depending on the context, the String literal is converted to the enum constant automatically. For example, in the following expression in which mySuit is an instance of Suit, "hearts" is first converted to a Suit.hearts before it is compared to the instance.

${mySuit == "hearts"}

So I don't think it is needed or even right to use the fully qualified name. So

${status=="rejected"}

might work (or "Rejected", "REJECTED", …. depending on what you used)

frederikherema1
Star Contributor
Star Contributor
Thanks for digging that up, Ronald. JUEL indeed threats enums-comparisons as string-values, according to the EL-spec…

tse
Champ in-the-making
Champ in-the-making
Thanks for the answer. In case of enums thats exactly what i have done as a workaround. Having a broader context in mind, comparison of strings is not always the case. What if you have to compare objects (constants most of the time). Then u probably need a class full package name: a.b.c.Clazz.FIELD.
In JSR-223 3.1 i've found something like T(a.b.c.Clazz).FIELD to solve this. Don't know which version is activiti compliant with but T(..) syntax does not work Smiley Sad

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
What is JSR-233 3.1 (I know what JSR-233 is, just can not find any specific reference to '3.1' anywhere. Do you have a link?

Otherwise simply write a method that accepts your input and compares the result there IN JAVA and returns a boolean….

${myCDIBean.isEqualToField(myField)}
and the bean:


import a.b.c.Clazz.Field

@Named
public class MyCDIBean {

    public boolean isEqualToField(a.b.c.Clazz.Field myValue) {
        return Field == myValue;
    }
}

Or something like this…