Hi JohnE,

> I am wondering if you can help me with a looping question.  I looked through 
> the user forum and found a good example by Shinobu.  In trying to duplicate 
> it, I am getting odd results.   My use is below:
> 
>  #set ($wrapper = $iteratorWrap.wrap($largeCollectionOfStuff))
>  #foreach ($item in $wrapper)
>    #if ($velocityCount >= $endingRecord)
>      $wrapper.stop()
>    #elseif ($velocityCount >= $beginningRecord)
>       $item.toString()
>    #end
>  #end
> 
> This seems pretty straight forward, but using it as such only causes one item 
> to print out once.  It only executes the foreach once.
> 
> When I place $wrapper.more() before the last #end, it causes it to cycle 
> through all of the records but it also causes the records to print out.  I do 
> not want a print out.

more() needs to be called in order to go forward.  You can do something like
  #set($garbage = $wrapper.more())
to not print the result.  But maybe a wantMore() will be a good RFE.  ;)

> Also I am wondering how a "continue" might be handled.   I am not very sure 
> how velocity parsing would be handled if it has to parse to the last #end on 
> each loop when the #end can be past lots of logic.    I would think having 
> not just a #stop (aka break) would be useful, but a #continue.

Actually, #stop stops Velocity, not just #foreach.  Using #if is the
only solution for a "continue" that I can think of right now.
  http://jakarta.apache.org/velocity/user-guide.html#Stop

Best regards,
-- Shinobu

--
Shinobu Kawai <[EMAIL PROTECTED]>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to