Please do not use this list for simple questions - it is reserved for discussion Drools development itself.<br><br>(1) The "exists(Account)" is superfluous; existence is implied by the match in the next Conditional Element.<br>
(2) The rule should match once and only once for each Account fact inserted into Working Memory.<br><br>Reading the Drools Expert documentation might clarify this and more for you.<br><br>-W<br><br><br><br><div class="gmail_quote">
On 1 March 2011 09:53, pchenna <span dir="ltr"><<a href="http://prashanth.sc">prashanth.sc</a>@<a href="http://gmail.com">gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have a rule while calls doMenu to display options and modify data<br>
accordingly.But why this rule is getting called only once even thought<br>
"WHEN" condition is matching.Isn't it should be called every-time condition<br>
matches?<br>
<br>
rule "Check trans"<br>
dialect "java"<br>
when<br>
exists(Account())<br>
$account :Account()<br>
then<br>
doMenu($account,drools.getWorkingMemory());<br>
<br>
end<br>
<br>
rule "Credit"<br>
#some code here<br>
end rule<br>
<br>
rule "Debit"<br>
#some code here<br>
end rule<br>
<br>
<br>
function void doMenu(Account account,WorkingMemory wm) {<br>
<br>
String option = "1";<br>
//while(!option.equalsIgnoreCase("3")){<br>
<br>
option = JOptionPane.showInputDialog("1.Debit \n" +<br>
"2.Credit \n" +<br>
"3. Exit");<br>
<br>
if(option.equalsIgnoreCase("1")){<br>
<br>
String amount = JOptionPane.showInputDialog("Enter Amount to be<br>
Debited");<br>
double amt = Double.parseDouble(amount);<br>
Transaction t = new Transaction ( account, amt, Transaction.DEBIT);<br>
wm.insert(t);<br>
<br>
<br>
}else if(option.equalsIgnoreCase("2")){<br>
<br>
String amount = JOptionPane.showInputDialog("Enter Amount to be<br>
Credited");<br>
double amt = Double.parseDouble(amount);<br>
Transaction t = new Transaction ( account, amt, Transaction.CREDIT);<br>
wm.insert(t);<br>
}<br>
<br>
//}<br>
}<br>
<br>
Sorry if this question is very naive,tried searching in forums and couldn't<br>
find anything helpful.<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Activating-the-rule-tp2601621p2601621.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Activating-the-rule-tp2601621p2601621.html</a><br>
Sent from the Drools - Dev mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
</font></blockquote></div><br>