Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Boolean operations inside conditional tags

 
Jacob Fenwick
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • 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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see no EL statement in the code you posted.

(That's a strong hint).
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jacob, do you know the 'empty' operator ?
${empty param.returnuri}
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic