It&#39;s impossible to diagnose exactly what goes on without seeing the LHS patterns in detail. One possible reason for the rules rule[234] in groupX not firing the second time that group is given focus is that none of the objects participating in the LHS of the three rules has changed since the first time.<br>
<br> Mixing condition evaluation by pattern matching with explicit control via a-groups and the like is tricky and apt to create surprises galore. Try to write the LHS so that they fully express the condition for firing; use groups only as a last resort.<br>
<br>Hint: duplication of RHS code can be avoided by defining and calling functions.<br><br>-W<br><br><br><div class="gmail_quote">On Wed, Jun 24, 2009 at 4:42 AM, new2drools <span dir="ltr">&lt;<a href="mailto:rkbeach@gmail.com">rkbeach@gmail.com</a>&gt;</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;"><br>
Hi All,<br>
<br>
Need some help with understanding setFocus.<br>
<br>
I have the following use case:<br>
<br>
if (condition1) {<br>
<br>
  if (condition2) {<br>
<br>
  } else if (condition3) {<br>
<br>
  } else if (condition 4) {<br>
<br>
  }<br>
<br>
}<br>
<br>
if (condition5) {<br>
<br>
  if (condition2) {<br>
<br>
  } else if (condition3) {<br>
<br>
  } else if (condition 4) {<br>
<br>
  }<br>
<br>
}<br>
<br>
I created 3 rules (rule2, rule3, rule4) for checking condition2, condition3,<br>
condition4 and<br>
created 1 agenda group (groupX) for them.<br>
<br>
I created 2 rules (rule1, rule5) for checking condition1, condition5 and<br>
created 1 agenda group(groupY) for them.<br>
<br>
rule &quot;rule1&quot;<br>
  agenda-group &quot;groupY&quot;<br>
<br>
  when<br>
    //<br>
  then<br>
   drools.setFocus(&quot;groupX&quot;);<br>
end<br>
<br>
rule &quot;rule3&quot;<br>
  agenda-group &quot;groupX&quot;<br>
  activation-group &quot;someActiveGroup&quot;<br>
<br>
  when<br>
    //<br>
  then<br>
   //<br>
end<br>
<br>
&gt;From the java code:<br>
<br>
ksession.getAgenda().getAgendaGroup(&quot;groupY&quot;).setFocus();<br>
<br>
Problem: The first time, drools.setFocus(&quot;groupX&quot;) is invoked, I see that<br>
it&#39;s working fine. rule2 or rule3 or rule4 get triggered. But, the SECOND<br>
time that drools.setFocus(&quot;groupX&quot;) is invoked, I don&#39;t see that any rule in<br>
agenda-group groupX is being invoked...even though one of the rule&#39;s LHS<br>
explicitly matches...thinking that the activation-group is cancelling all<br>
the activation&#39;s (after one rule in that activation group is fired), I even<br>
removed the activation-group statement. But, it didn&#39;t help...ideally, I<br>
would like to bunch rule2, rule3, rule4 in one activation group.<br>
<br>
Can you please let me know as to why the second invocation of setFocus is<br>
not working? I even tried to remove everything in LHS of rule2/3/4, to see<br>
if the second invocation would work...it doesn&#39;t...<br>
<br>
Thanks!!<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/Need-help-with-setFocus-tp24177742p24177742.html" target="_blank">http://www.nabble.com/Need-help-with-setFocus-tp24177742p24177742.html</a><br>
Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>