+1 from me....go the commit.
--
dIon Gillard, Multitask Consulting
Work:      http://www.multitask.com.au
Developers: http://adslgateway.multitask.com.au/developers


"Waldhoff, Rodney" <[EMAIL PROTECTED]> wrote on 22/10/2002 
10:09:24 AM:

> 
> I frequently find myself writing Jelly scripts like:
> 
> <j:choose>
>   <j:when test="${some.complicated.expression().equals('foo')}">
>     <!-- do something -->
>   </j:when>
>   <j:when test="${some.complicated.expression().equals('bar')}">
>     <!-- do something else -->
>   </j:when>
>   <!-- ... -->
>   <j:otherwise>
>     <!-- do something else -->
>   </j:otherwise>
> </j:choose>
> 
> The redudancy of some.complicated.expression() is required, since 
> choose/when/otherwise is implementing an if/else if/else expression.
> What I really want is a switch/case expression, e.g.,:
> 
> <j:switch on="${some.complicated.expression()}">
>   <j:case value="foo">
>     <!-- do something -->
>   </j:case>
>   <j:case value="bar">
>     <!-- do something else -->
>   </j:case>
>   <!-- ... -->
>   <j:default>
>     <!-- do something else -->
>   </j:default>
> </j:switch>
> 
> (I am aware that I could set/unset a variable to factor out "some.
> complicated.expression()", but that doesn't solve the problem very 
> elegantly, IMO. Also true switch/case/default support lets you do 
> more interesting things than if/else--like doubling up cases by 
> "falling thru".)
> 
> The attached patch adds support for these tags, as well as a few 
> simple unit tests for them.
> 
> PS: I already have karma to commons and commons-sandbox and hence 
> can commit this directly if you want to avoid dealing with the patch
> itself.  I just wanted to run this by everyone first.
> 
> - R.
> [attachment "CoreTagLibrary.java.diff.txt" deleted by dIon 
> Gillard/Multitask Consulting/AU] [attachment "CaseTag.java" deleted 
> by dIon Gillard/Multitask Consulting/AU] [attachment "DefaultTag.
> java" deleted by dIon Gillard/Multitask Consulting/AU] [attachment 
> "SwitchTag.java" deleted by dIon Gillard/Multitask Consulting/AU] 
> [attachment "TestSwitchTag.java" deleted by dIon Gillard/Multitask 
> Consulting/AU] [attachment "testSwitchTag.jelly" deleted by dIon 
> Gillard/Multitask Consulting/AU] --
> To unsubscribe, e-mail: 
<mailto:commons-dev-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail: 
<mailto:commons-dev-help@;jakarta.apache.org>
> ForwardSourceID:NT000837F2 

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>

Reply via email to