The problem is that $eventSet is a List<Object> and not List<Value>.
So you need to cast and use the old for loop:
for(int i=0; i < $eventSet.size();i++){
Value value = (Value)$eventSet.get(i);
}
Greetings.
Yeah, I think using a normal for loop is better. I just came up with the question because I wanted to use a for-each-loop in a simple exercise-scenario, because it's a bit faster to write...
Anyway, what I wanted to do is:
for (Value value : $eventSet) {
// raise hell
}
Thats where I get the type mismatch.
Thanks :)
Tina
E.g., Joshua Bloch, "Effective Java", Item 46: Prefer for-each loops to traditional for loops. Plain old Java.
-W
2010/8/12 Mauricio Salatino <salaboy@gmail.com>
Probably I misread the question.. I thought that Tina was asking about for each loops in Drools Flow.
If not where are you using for each??
A java for each each node in the RHS?
Greetings.
2010/8/12 Wolfgang Laun <wolfgang.laun@gmail.com>
I'm not sure whether you and Salboy are on the same wavelength. Tina, please do provide more
details where and what you want to for-each-loop. Guessing is a waste of time...
-W
2010/8/12 Tina Vießmann <tviessmann@stud.hs-bremen.de>
Oh, do I need a loop xml definition? Good to know. -.-
Could you give me a link with a good explanation/example about how to do this?
Thanks :)
Tina
The for each loop in Drools Flow recieves a list of objects to iterate over it.
Can you share your loop xml definition? and can you check that the variable that it's using is a list?
On Thu, Aug 12, 2010 at 1:08 PM, Tina Vießmann <tviessmann@stud.hs-bremen.de> wrote:
Hi,
is it possible to use the for each loop in Drools?
The engine grouses a type mismatch : cannot convert from element type
Object to Value
Thanks :)
Tina
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
- CTO @ http://www.plugtree.com
- MyJourney @ http://salaboy.wordpress.com
- Co-Founder @ http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
- CTO @ http://www.plugtree.com
- MyJourney @ http://salaboy.wordpress.com
- Co-Founder @ http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users