"While"-like structure in Velocity?

Christopher Schultz <[email protected]>
Newsgroups gmane.comp.jakarta.velocity.user
Message-ID <[email protected]>
All,

I've searched the archives for "while" capabilities in Velocity, and
mostly the answers have been things like "that's beyond the scope of
Velocity... you want a real programming language for that".

I'd like to do something that naturally would use a while loop, but
perhaps someone can offer an alternative suggestion.

I need to traverse a queue, but that queue needs to be able to modify
itself during the processing. Basically, something like this:

while (!queue.empty) {
  // do something with the head element
  // possible enqueue some more items at the back
}

#foreach would be the way to do it if the queue didn't have to be
modified, but I'll get an exception if I try to traverse an iterator
over the queue and then modify it mid-flight.

Right now, I have this written as a JSP but I'd rather have it as a
Velocity template.

My only thought is to create an ugly class that implements Iterator and
wraps the queue but is much less strict than a standard iterator. Any
suggestions?

-chris
signature.asc (application/pgp-signature, 946 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJRk7OdAAoJEBzwKT+lPKRYirUP/3lpG2h6U1HqsHW1aAauZX1g
rfyvfx/CgkjDVYrpZcCyx0mRHzgvymWs4KY6r6sj795SRWRFlLAX4Kxlcek9KONO
xTvBhxYYQUY7asZlnAoKqBMJTuNSJyjHUl47n5fflJ7nVIu7jZoIRsabmfqYZajo
oc+jJ156eAnLBNzMsfAfN6KVnQw9h9lsT7js7ym9FizJWncHMGBS+SJiUAw6/oT/
EnEaHkqGOdNzuRXBgdB5ojqa9/rad6zgz+4SWocVRhUCxq/gOrJdkaEWFWia8Ws+
aqPo7ABNeukY/84WvTGy0R4H/Xyr2ywGdNNibORUbmdxTKxvujeeKbGSioQMFlhG
KSkElJm+nFlYd+XImGx7KjACeySJH0BL/MjbBeSYt67aDvZfWC1n5QoDzcykXLw6
5RRbZ045+Mka+PIjDqr6cKiLfzxD1gVlMU7+b327mHc+fuQRHuHUvgDiMj8iD396
b19nc1X/CmQROX3Lz4TZWp6uNuahapj10C1R3a4aPpY1QP3LdrMMFqJzS2MwiVj+
xlGBHIMLaWKDVQStHzJiKR9CHlQ+Vv3JR1/7CJP5vzmRK9vkozvl2FimwwkCpov8
xf8O1782Ly4gkczw1wJfI197DoPNxm/u0ixauvqmaXQ5dYkMHPT+ZUPkRi+/a5yK
NT6LFaYQlKnREaLBnZhk
=SL6O
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.