I have a rule while calls doMenu to display options and modify data
accordingly.But why this rule is getting called only once even thought
"WHEN" condition is matching.Isn't it should be called every-time condition
matches?

rule "Check trans"
        dialect "java" 
        when
                exists(Account())
            $account :Account()
        then
                doMenu($account,drools.getWorkingMemory());             

end

rule "Credit"
#some code here
end rule

rule "Debit"
#some code here
end rule


function void doMenu(Account account,WorkingMemory wm) {
        
        String option = "1";
        //while(!option.equalsIgnoreCase("3")){

        option = JOptionPane.showInputDialog("1.Debit \n" +
                                                "2.Credit \n" +
                                                "3. Exit");
        
        if(option.equalsIgnoreCase("1")){
        
                String amount  = JOptionPane.showInputDialog("Enter Amount to be
Debited");
                double amt = Double.parseDouble(amount);        
                Transaction t = new Transaction ( account, amt, 
Transaction.DEBIT);
                wm.insert(t);
                
                
        }else if(option.equalsIgnoreCase("2")){
        
                String amount  = JOptionPane.showInputDialog("Enter Amount to be
Credited");
                double amt = Double.parseDouble(amount);        
                Transaction t = new Transaction ( account, amt, 
Transaction.CREDIT);
                wm.insert(t);
        }
        
//}                     
}

Sorry if this question is very naive,tried searching in forums and couldn't
find anything helpful.

-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Activating-the-rule-tp2601621p2601621.html
Sent from the Drools - Dev mailing list archive at Nabble.com.
_______________________________________________
rules-dev mailing list
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev

Reply via email to