You are right; your probably need to set a no-loop atttribute on your rule.
Or, preferably, put additional conditions to the LHS of your FirstRule
(it would probably be the case in a "real-life" rule).
As Wolfgang suggested, take some time to read Drools expert
documentation: I found it very well designed for beginners (like me).
Regards,
Bruno.
Le 12/05/2011 11:19, Nico ROEDERER a écrit :
Ok, but when I did this, the first rule has no ending.
If I don't want to, I've got to retract the object, but my second rule
is never fired.
Should I make two different files ?
Thanks for the help.
(Sorry for such a poor English writing :( )
Le 12/05/2011 11:12, Bruno Freudensprung a écrit :
>
> Hi,
>
> In my understanding it is normal. However if you told Drools that
> your FirstRule modified the $testDrools object, it should no longer
> be the case:
>
> then
> System.out.println("Set my value to 1");
> $testDrools.setMyValue("1");
> update($testDrools);
>
> Regards,
>
> Bruno.
>
>
> Le 12/05/2011 10:58, Nico ROEDERER a écrit :
>> Hi,
>>
>> I've got a little question. I've got a drl file which contains two
>> rules :
>>
>> rule "FirstRule"
>> salience 99
>> when
>> $testDrools : TestDroolsDto()
>> eval ( 1 == 1 )
>> then
>> System.out.println("Set my value to 1");
>> $testDrools.setMyValue("1");
>>
>> end
>>
>> rule "SecondRule"
>> salience 1
>> when
>> $testDrools : TestDroolsDto()
>> eval( $testDrools.getMyValue().equals("") )
>> then
>> System.out.println("My Value : " + $testDrools.getMyValue() );
>> end
>>
>> Is it normal that in my second rule is verified ?
>> -> eval( $testDrools.getMyValue().equals("") ) is true
>> but : System.out.println("My Value : " + $testDrools.getMyValue() );
>> show me that myValue == 1
>>
>> Perhaps I did something wrong ?
>>
>> Thanks for your helping me.
>> N.
>>
>>
>>
>> PS : Here is me TestDroolsDto :
>> public class TestDroolsDto {
>> private String myValue;
>>
>> public TestDroolsDto() {
>> myValue="";
>> }
>>
>> public String toString() {
>> return " --> " + myValue;
>> }
>>
>> /**
>> * @return the myValue
>> */
>> public String getMyValue() {
>> if ( myValue == null ) {
>> myValue = "";
>> }
>> return myValue;
>> }
>>
>> /**
>> * @param myValue the myValue to set
>> */
>> public void setMyValue( String myValue ) {
>> this.myValue = myValue;
>> }
>> }
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>