You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Sukhenko, Mikhail (Contr)" <MS...@northropgrumman.com> on 2002/10/15 23:51:32 UTC

using OR condition with logic tags

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

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


Re: using OR condition with logic tags

Posted by Eddie Bush <ek...@swbell.net>.
Oh --- OR --- I was thinking ELSE.  Sorry.

JSTL solution:

<c:if test="${(foo == 1) || (foo == 2)}">
    <!-- relevant code -->
</c:if>

The Struts-based solution would be the same as I mentioned before, I 
believe.  Sorry - I somehow understood you wanted an ELSE!

chanoch wrote:

>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")
>
>chanoch
>

-- 
Eddie Bush




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


Re: using OR condition with logic tags

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 16 Oct 2002, chanoch wrote:

> Date: Wed, 16 Oct 2002 20:10:47 +0100
> From: chanoch <ma...@chanoch.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> 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" <ek...@swbell.net>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> 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:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


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


Re: using OR condition with logic tags

Posted by chanoch <ma...@chanoch.com>.
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")

chanoch


----- Original Message -----
From: "Eddie Bush" <ek...@swbell.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
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:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


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


Re: using OR condition with logic tags

Posted by Eddie Bush <ek...@swbell.net>.
<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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>