velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lloyd <subscr...@twilight-systems.com>
Subject Re: "Could not determine type of iterator in #foreach loop"
Date Tue, 13 Aug 2002 13:52:50 GMT
Geir Magnusson Jr. wrote:

 > What that message means is that it couldn't even figure out how to get
 > something to iterate over.  Do you do  :
 >
 >    context("revs", thingy.getIterator());


No, more like this:

class BaseThingy {
   private class ThingyIterator implements Iterator {...}
   public Iterator iterator() { return (Iterator) new ThingyIterator() }

...

class Thingy extends BaseThingy {...}

...

class Revenues
   private Thingy thingy;
   public getThingy() { return thingy }

...

Revenues revenues = new Revenues()

context.put("revs", revenues)

...

#set( $thingy = $revs.thingy )

#foreach( $thing in $thingy )

    ## where the hell are my thingies?

#end


So, I don't put an iterator in the context; I put an object that has an 
iterator() method.






--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message