<p>You might be looking for accumulate or collect patterns. You will find all the information you need in the manual.</p>
<p>Best,</p>
<p><blockquote type="cite">El jul 30, 2010 11:22 a.m., "Dinesh kumar" <<a href="mailto:dinp87@gmail.com">dinp87@gmail.com</a>> escribió:<br><br><br>
Hi,<br>
<br>
I am facing problems in iterating a list in guvnor.<br>
<br>
I tried the following code and it worked.<br>
<br>
import java.util.ArrayList;<br>
rule createValidationReport<br>
dialect 'java'<br>
when<br>
ClaimRegistration($ailmentList : ailmentListFromScreen)<br>
then<br>
for(String ailment : (ArrayList<String>) $ailmentList){<br>
System.out.println("ailment "+ailment);<br>
}<br>
System.out.println("then");<br>
end<br>
<br>
<br>
But my requirement is to iterate the list in the when block and process<br>
something based on the data in the list.<br>
<br>
It should be something like<br>
<br>
import java.util.ArrayList;<br>
rule createValidationReport<br>
dialect 'java'<br>
when<br>
<br>
ClaimRegistration($ailmentList : ailmentListFromScreen)<br>
for(String ailment : (ArrayList<String>) $ailmentList){<br>
System.out.println("ailment "+ailment);<br>
// My condition needs to be evaluated here<br>
}<br>
then<br>
<br>
System.out.println("then");<br>
<br>
end<br>
<br>
<br>
Need help on this issue. Is this possible in Drools?<br>
kindly advice.<br>
<br>
Regards,<br>
Dinesh<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/How-to-Iterate-list-in-drools-tp1008987p1008987.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/How-to-Iterate-list-in-drools-tp1008987p1008987.html</a><br>
Sent from the Drools - User mailing list archive at Nabble.com.<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></p>