[rules-users] Problem with class Variable

Mark Proctor mproctor at codehaus.org
Mon Nov 26 12:47:35 EST 2007


Mehdi wrote:
> hi,
>
> I have a class Customer.java with class variable "allTradeAmounts" and
>
> I have two rules as follows:
>
> rule "rule 1"
>     when
>         $c : Customer();
>     then
>             
>         $c.setAllTradeAmounts($c.getAllTradeAmounts().add(1000));  
>        System.out.println("after modify: "+$c.getAllTradeAmounts());
how does the engine know this has changed? call:
update($c);
> end
>
> rule "rule 2"
>     when
>         $c : Customer(allTradeAmounts < 200 );
>     then
>         System.out.println("AllTradeAmounts < 200 ");
>
> end
>
> The rule 1 works fine and changes the value of this variable.
> My question is, although the rule 1 has changed the class variable and 
> I can see the result of changed variable EACH TIME, when i insert a 
> Customer object, why is the second rule TRUE? I have changed the value 
> of AllTradeAmounts and I can print it in RHS and it is more than 200, 
> but in LHS if I check with "allTradeAmounts < 200 " ,it is true.
> It must be FALSE and does not fire the rule.
> can someone help me? what do I do wrong in LHS.
> In the same rule (rule 2) if I print the allTradeAmounts it is more 
> than 200.
> sorry it is a simple question, but I m new to drools.
> Thanks and regards
>
> ------------------------------------------------------------------------
> Be a better sports nut! Let your teams follow you with Yahoo Mobile. 
> Try it now. 
> <http://us.rd.yahoo.com/evt=51731/*http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ> 
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20071126/171d1a26/attachment.html 


More information about the rules-users mailing list