You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Vinay Chandran <sa...@yahoo.com> on 2002/10/13 05:53:18 UTC

[Jelly]BreakTag

Hi,

[Attached BreakTag.java]

BreakTag [ <break if="condition"/> ] tag allows one to
conditionally 
break out of a script block without executing any
subsequent scripts within its parent .
The natural use is to break out of a <foreach/> ,
<while/> loop .
Break works in the context of any parent tag and thus
one can use
to conditionaly break out of the entire script itself.
[ testBreak.jelly attached ] 

Regards,
Vinay.

Patch to CoreTagLibrary 
------------------------
97a98
> 		registerTag("break",BreakTag.class);



__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

Re: [Jelly]BreakTag

Posted by James Strachan <ja...@yahoo.co.uk>.
Hi Vinay

I've finally gotten around to adding a BreakTag. The original patch modified
the Script objects, which are the static parsed image of a script and can be
cached and reused across threads. I changed the implementation to use
exception throwing to break out of loops. So to terminate from a <forEach>
or <while> loop, something just needs to throw a BreakException.

Thanks for the patch Vinay, its all applied to CVS HEAD now.

James
-------
http://radio.weblogs.com/0112098/

----- Original Message -----
From: "Vinay Chandran" <sa...@yahoo.com>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Sunday, October 13, 2002 4:53 AM
Subject: [Jelly]BreakTag


> Hi,
>
> [Attached BreakTag.java]
>
> BreakTag [ <break if="condition"/> ] tag allows one to
> conditionally
> break out of a script block without executing any
> subsequent scripts within its parent .
> The natural use is to break out of a <foreach/> ,
> <while/> loop .
> Break works in the context of any parent tag and thus
> one can use
> to conditionaly break out of the entire script itself.
> [ testBreak.jelly attached ]
>
> Regards,
> Vinay.
>
> Patch to CoreTagLibrary
> ------------------------
> 97a98
> > registerTag("break",BreakTag.class);
>
>
>
> __________________________________________________
> Do you Yahoo!?
> Faith Hill - Exclusive Performances, Videos & More
> http://faith.yahoo.com


----------------------------------------------------------------------------
----


> <?xml version="1.0"?>
>
> <!-- displays the current command line arguments -->
>
>
> <j:jelly xmlns:j="jelly:core">
>
> <!-- Setting a boolean var to true -->
> <j:set var="exitCompletely" value="true"/>
>
> <arguments>
>   <j:forEach var="arg" items="${args}" begin="1">
>       <!-- Break cond for the foreach loop -->
>       <j:break if='${arg=="three"}'/>
>       <argument>${arg}</argument>
>   </j:forEach>
> </arguments>
>
> <j:break if='${exitCompletely}'/>
> **************************
> These Should NOT  appear
> **************************
> </j:jelly>
>


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>