[rules-users] Problem with class Variable
Mark Proctor
mproctor at codehaus.org
Mon Nov 26 13:38:50 EST 2007
We are thinking of extending the java dialect with a modify command that
works like the mvel one; this would negate the need to use a separate
modify statement. Just a matter of getting time to do it :(
Mark
ekke wrote:
> 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
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20071126/5ef1014f/attachment.html
More information about the rules-users
mailing list