| Author |
Boolean operations inside conditional tags
|
Jacob Fenwick
Ranch Hand
Joined: Apr 28, 2006
Posts: 55
|
|
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 ]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
I see no EL statement in the code you posted. (That's a strong hint).
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
(That's a strong hint)
And it will cost Jacob a few dollars (that's another strong hint)
|
[My Blog]
All roads lead to JavaRanch
|
 |
Jacob Fenwick
Ranch Hand
Joined: Apr 28, 2006
Posts: 55
|
|
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
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
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
Joined: Apr 28, 2006
Posts: 55
|
|
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
Joined: Nov 24, 2005
Posts: 14685
|
|
Jacob, do you know the 'empty' operator ? ${empty param.returnuri}
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
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.
|
 |
 |
|
|
subject: Boolean operations inside conditional tags
|
|
|