[rules-users] Problem with class Variable

ekke ekkehard at gentz-software.de
Mon Nov 26 13:09:45 EST 2007


mehdi,

the rules engine has to know that your fact changed,
you can use PropertyChangeSupport
take a look at the documentation
2.5.4.4. Update
2.5.4.7. Property Change Listener
6.5.3. The Right Hand Side (then)

regards
ekke

Mehdi-6 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());
> 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.
> _______________________________________________
> 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-with-class-Variable-tf4876599.html#a13954697
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list