[rules-users] How to Iterate list in drools

Dinesh kumar dinp87 at gmail.com
Fri Jul 30 10:21:29 EDT 2010


Hi,

I am facing problems in iterating a list in guvnor.

I tried the following code and it worked.

import java.util.ArrayList;
rule createValidationReport
dialect 'java'
when
ClaimRegistration($ailmentList : ailmentListFromScreen)
then
for(String ailment : (ArrayList<String>) $ailmentList){
	System.out.println("ailment  "+ailment);
}
System.out.println("then");
end


But my requirement is to iterate the list in the when block and process
something based on the data in the list.

It should be something like 

import java.util.ArrayList;
rule createValidationReport
dialect 'java'
when

ClaimRegistration($ailmentList : ailmentListFromScreen)
for(String ailment : (ArrayList<String>) $ailmentList){
	System.out.println("ailment  "+ailment);
        // My condition needs to be evaluated here
}
then

System.out.println("then");

end


Need help on this issue. Is this possible in Drools? 
kindly advice.

Regards,
Dinesh

-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-Iterate-list-in-drools-tp1008987p1008987.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list