views:

57

answers:

1

I'm working on a GWT project, and I have a bunch of Java classes that use Java Object Iterators on the server side. As I was reading through the internet...Iterators seem to not be serializable preventing me from sending them over to the client side from the server side. My question is is there an efficient way to serialize the iterator or use a substitute that might be serializable ?

Many thanks!

+1  A: 

Conceptually speaking, iterators don't exist on their own, they're just a convenience interface for accessing a collection of some sort our another. What you will need to do is serialize the collection that you got the iterator from. If that's not possible, you could run over the Iterator and add each object it returns to an ArrayList, send that to the client, then call iterator() from there.

hambend
thank you so much
Mahmoud