On Wed, 16 Oct 2002, chanoch wrote:
> Date: Wed, 16 Oct 2002 20:10:47 +0100
> From: chanoch <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: Re: using OR condition with logic tags
>
> however, this is quite ugly - you end up having to write two outputs for
> what is basically the same problem, hence the reference to OR.
>
> That means maintaining two Stuff's which are identical
>
> thoughts? (except for suggesting tiles which confused my designer guys
> completely - they already are trying to work out why I am "designing new
> HTML elements")
>
Again using JSTL (Servlet 2.3 / JSP 1.2 container is required), you can
use the "||" operator to implement an OR:
<c:if test="${(foo == '1') || (foo == '2')}"/>
... stuff when foo is 1 or 2 ...
</c:if>
The expression language in JSTL 1.0 (and also in JSP 2.0, where you can
even use it in template text) is likely to become a JSP page author's best
friend. But if you're stuck on a Servlet 2.2 / JSP 1.1 based server,
you're best bet is probably to write your own custom tag that implements
the test you are after.
> chanoch
>
Craig
>
> ----- Original Message -----
> From: "Eddie Bush" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Sent: Tuesday, October 15, 2002 11:26 PM
> Subject: Re: using OR condition with logic tags
>
>
> > <logic:equal name="foo" value="1">
> > <!-- Stuff for when foo == 1 -->
> > </logic:equal>
> > <logic:equal name="foo" value="2">
> > <!-- Stuff for when foo == 2 -->
> > </logic:equal>
> >
> > -- OR -- JSTL Approach 1
> >
> > <c:choose>
> > <c:when test="${foo == 1}">
> > <!-- Stuff for when foo == 1 -->
> > </c:when>
> > <c:when test="${foo == 2}">
> > <!-- Stuff for when foo == 1 -->
> > </c:when>
> > </c:choose>
> >
> > -- OR -- JSTL Approach 2
> >
> > <c:choose>
> > <c:when test="${foo == 1}">
> > <!-- Stuff for when foo == 1 -->
> > </c:when>
> > <c:otherwise>
> > <!-- Stuff for when foo == 1 -->
> > </c:otherwise>
> > </c:choose>
> >
> > Sukhenko, Mikhail (Contr) wrote:
> >
> > >Hey, guys!
> > >Do any of you know how to set up an OR condition with logic:equal tags?
> > >i.e. :
> > >
> > ><logic:equal name="foo" value="1"> OR <logic:equal name="foo" value="2">
> > >
> > >Thanks
> > >
> >
> > --
> > Eddie Bush
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>