[rules-users] For each - properties

Bill Tarr javatestcase at yahoo.com
Mon Oct 5 10:39:37 EDT 2009


Betto,

I just went down this road with ForEach in DroolsFlow.  The documentation on those properties was a little lacking in my opinion.

CollectionExpression = should be an expression that resolves to a java.util.Collection.  So a Person has a List<Loans>, and your flow has a variable person which you set, the expression could be:

person.loans

VariableName = is the name given to the current item you are passing in.  Perhaps just loan.  That is the variable that will be passed into your subflow (or RuleGroup in your case.)

I did a similar thing with for a demo, but ran into another problem.  I called a Subflow from within the ForEach, and passed in my variable (lets say loan.)  I could access the variable easily enough in Actions, using code - like 

loan.getStatus().equals("Approved") 

but have not been able to get a RULE to execute against that variable.  Like

$loan : Loan (status == "Approved")

Not sure what the problem was with my code, but will revisit later.

I bring that up in case you run into it because you are just calling a rule within  your ForEach.  Maybe try a simple code action first, something like

System.out.println(loan.getStatus());

Anyway, let me know how it goes.  Kind of nice to see someone going down the same road...

Bill

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




More information about the rules-users mailing list