<br> 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. <br><br> You need to call the equals() method:<br>
<br>eval( functionThatReturnsString().equals("1234) )<br><br> []s<br> Edson<br><br><div class="gmail_quote">2009/7/7 rainbowflower <span dir="ltr"><<a href="mailto:al_aysha@yahoo.co.in">al_aysha@yahoo.co.in</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hi all,<br>
<br>
I am rather new to Drools and I have a problem using functions.<br>
<br>
I have a rule like:<br>
<br>
rule "rule 1"<br>
when<br>
eval(getEVAVersionsNr() == "1234")<br>
then<br>
System.out.println("rule fired");<br>
end<br>
<br>
The getEVAVersionsNr() method is present in a Java class<br>
"ValidationUtilities.java", which I'm importing in my drl file and it looks<br>
like this:<br>
<br>
public class ValidationUtilities {<br>
<br>
public static String evaVersionsNr;<br>
<br>
public static String getZEVAVersionsNummer() {<br>
return evaVersionsNr;<br>
}<br>
}<br>
<br>
This static attribute "evaVersionsNr" is set to "1234" from another Java<br>
class before I fire my rules. So, I assume that the eval construct should<br>
return true. But, it does not return true and the consequence is not<br>
exected.<br>
<br>
Further info:<br>
<br>
When I modify my rule like:<br>
<br>
rule "rule 1"<br>
when<br>
eval(true)<br>
then<br>
System.out.println(getEVAVersionsNr());<br>
end<br>
<br>
the consequence part is getting executed and 1234 is getting printed.<br>
<br>
I am really lost and I could not find out what goes wrong. If someone could<br>
find out what I am missing, I shall be thankful.<br>
<br>
Thanks in advance.<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/Problem-calling-a-function-returning-String-tp24375624p24375624.html" target="_blank">http://www.nabble.com/Problem-calling-a-function-returning-String-tp24375624p24375624.html</a><br>
Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>