[rules-users] [droolsflow] ForEach usage - Version 5.1.0 (Anderson vasconcelos)

Bill Tarr javatestcase at yahoo.com
Thu Oct 8 02:33:49 EDT 2009


Anderson,

Could you describe what behavior you are getting when you put a collection in the CollectionExpressions?

I've used a process variable object like FactObject with a List (lets say a List<SubFacts> subFct ) on it.  I pass in the FactObject, and make it a named variable in my workflow factObj, and put  

CollectionExpression => factObj.subFct
variable => currentSubFact, 

I can use that variable within my ForEach loop no problem.  My setup is to pass that variable into a subflow, but I don't think that is important.

I may be missing something, is you case different somehow?

Bill


Hi All
To use a ForEach element i need to access a collection inside my
FactObject.  (FactObject.list)
I tried to call FactObject.list inside a CollectionExpressions but this
fail. (Just ok with list defined as a process variable)
*So i do something thats a consider a workaround:*

1- I Create a '"Action Node" before a "ForEach Node"

2-In the "Action Node", i get the FactObject and populate the process
variable that represents FactObject.list :
*FactObject factObject =
(FactObject)drools.getKnowledgeRuntime().getObjects(new
ClassObjectFilter(FactObject.class)).iterator().next();
context.setVariable("list", factObject.getDefeitos());*

3- And on the "Foreach node" i just  passed the "list" in the
CollectionExpressions

This is the correct way to do this? Has a better way to get FactObject.list
to use on "For Each Node"?

On Eclipse, the CollectionExpression of forEach don't have a window (Like
Action Editor) to put a MVEL/Java expressions. I think this is a interesting
resource.


      




More information about the rules-users mailing list