On Tue, Dec 13, 2005 at 11:02:02AM +0100, Rolf Niepraschk wrote:
> can you tell me if it is possible to break a simple forEach loop
> premature. The following doesn't work:
> 
> <c:forEach begin="1" end="30" varStatus="status">
>   ${status.count}<br>
>   <c:if test="${status.count==10}">
>     <c:set var="status.count" value="31" />
>   </c:if>
> </c:forEach>

        that's because the status variable is read-only.  It has no setCount()
method.
        The easiest way, if you really can't find anyway around it, which
will probably work, is just:
<% break; %>

        but the best way is probably to re-write your loop so you don't
need to do this.

        Alternately, you could write a custom tag that uses
findAncestorWithClass() to grab the LoopTagSupport object (i.e. the
c:forEach tag object) and try using introspection to set the "end"
property.  (or make the specific to apache taglibs and cast it to
a org.apache....ForEachTag object and call setEnd() directly)

eric

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

Reply via email to