[rules-users] Problem calling a function returning String
rainbowflower
al_aysha at yahoo.co.in
Wed Jul 8 05:23:13 EDT 2009
Hallo Edson,
The equals() usage had solved my problem. Thanks for your quick reply, :-)
It was so simple but didnt occur to me.
Barton, my sequence had been
ValidationUtilities.evaVersionsNr = "1234";
<make session>
fireAllRules()
only. However, i agree with the risk in using
ValidationUtilities.evaVersionsNr which is a public static member. I shall
look into changing my approach. Thanks for your help too.
Have a nice day.
Edson Tirelli-3 wrote:
>
> 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 at 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-tp24375624p24375624.html
>> Sent from the drools - user mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
>
> --
> Edson Tirelli
> JBoss Drools Core Development
> JBoss by Red Hat @ www.jboss.com
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
View this message in context: http://www.nabble.com/Problem-calling-a-function-returning-String-tp24375624p24388155.html
Sent from the drools - user mailing list archive at Nabble.com.
More information about the rules-users
mailing list