Remember that inside the eval() block, since you are using java dialect,
what you have is java code. So, == is checking for String identity, that is
not what you want.
You need to call the equals() method:
eval( functionThatReturnsString().equals("1234) )
[]s
Edson
2009/7/7 rainbowflower <al_aysha(a)yahoo.co.in>
Hi all,
I am rather new to Drools and I have a problem using functions.
I have a rule like:
rule "rule 1"
when
eval(getEVAVersionsNr() == "1234")
then
System.out.println("rule fired");
end
The getEVAVersionsNr() method is present in a Java class
"ValidationUtilities.java", which I'm importing in my drl file and it
looks
like this:
public class ValidationUtilities {
public static String evaVersionsNr;
public static String getZEVAVersionsNummer() {
return evaVersionsNr;
}
}
This static attribute "evaVersionsNr" is set to "1234" from another
Java
class before I fire my rules. So, I assume that the eval construct should
return true. But, it does not return true and the consequence is not
exected.
Further info:
When I modify my rule like:
rule "rule 1"
when
eval(true)
then
System.out.println(getEVAVersionsNr());
end
the consequence part is getting executed and 1234 is getting printed.
I am really lost and I could not find out what goes wrong. If someone could
find out what I am missing, I shall be thankful.
Thanks in advance.
--
View this message in context:
http://www.nabble.com/Problem-calling-a-function-returning-String-tp24375...
Sent from the drools - user mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @
www.jboss.com