• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Boolean operations inside conditional tags

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I run this code, I get True test failed. I would have thought that I would get True test passed since you can do boolean operations inside an EL statement.


[ July 06, 2006: Message edited by: Jacob Fenwick ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see no EL statement in the code you posted.

(That's a strong hint).
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

(That's a strong hint)


And it will cost Jacob a few dollars (that's another strong hint)
 
Jacob Fenwick
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, so it doesn't actually contain an expression. I thought the part where the test attribute was evaluated was an expression, but I guess an expression is actually anything where ${x} is replaced by x.
What would you call the test attribute that gets evaluated?
The original statement where I was having the problem did have an expression in it. I've included it below.
At first I thought it might not have worked because EL didn't recognize null, but then I did the test with the two trues that are OR'd together and saw it fail, so now I want to know why you can't OR two statements inside a c:when tag or a c:if tag, or whatever other conditional tag you might use.



[ July 06, 2006: Message edited by: Jacob Fenwick ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jacob Fenwick:
Ok, so it doesn't actually contain an expression. I thought the part where the test attribute was evaluated was an expression, but I guess an expression is actually anything where ${x} is replaced by x.



All EL expressions are enclosed in the ${} delimiters. In your example

<c:when test="true || true">



there is no EL expression. The value passed to the test attribute is the string "true || true".

If you want it to be an EL expression, you need to use the correct syntax:



then I did the test with the two trues



As I pointed out, you did not. Your test is flawed as described.

now I want to know why you can't OR two statements



You can.
 
Jacob Fenwick
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear. I was going to ask another question because I was still having problems but I figured it out. Oh well, I'll post what I learned anyways since I already typed it.

I thought something like this might work:

If I only put in param.returnuri==null and then didn't pass a variable, or if I only use param.returnuri=='null' and then pass the variable null, then it works. But as soon as I add in the OR, it stops working.

This was ludicrous but I tried it anyways:

Of course it's not proper syntax so it failed.

I finally did:

[ July 06, 2006: Message edited by: Jacob Fenwick ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jacob, do you know the 'empty' operator ?
${empty param.returnuri}
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I finally did:



Yes, the ${} encloses the entire EL expression. It is not some sort of fetch operator. This is a common misconception, so don't feel too bad about it.

And, as Satou pointed out, the empty operator will return true if the operand is null or the empty string.
 
reply
    Bookmark Topic Watch Topic
  • New Topic