[rules-users] Problem calling a function returning String

rainbowflower al_aysha at yahoo.co.in
Tue Jul 7 11:33:18 EDT 2009


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-tp24375624p24375624.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list