| Author |
c:if and c:choose
|
Henrik Krievs
Ranch Hand
Joined: Jan 05, 2004
Posts: 59
|
|
Must c:if/c:choose have an EL as test parameter ? In HF all examples uses EL. Isn't it possible to write something like <c:if test="1 < 2"> ? Rgds, Henrik
|
 |
pallavi utukuri
Ranch Hand
Joined: Feb 10, 2004
Posts: 182
|
|
what is test="1 < 2" ??? it just evaluates to null and its treated as false by default <c:if test="1 < 2" var="x"/> result is:${x} this evaluates to result is:false
|
Thanks,<br />Pallavi
|
 |
Henrik Krievs
Ranch Hand
Joined: Jan 05, 2004
Posts: 59
|
|
I'm sorry but I really don't get it. <c:if test="1 < 2" var="x"/> result is:${x} Output: result is:false But that doesn't proove anything. 1 < 2 - usually resolves to true ;-) What I want to know: Is it possible to put anything than EL in the test attribute AND make it work ? Rgds, Henrik
|
 |
Kathy Sierra
Cowgirl and Author
Ranch Hand
Joined: Oct 10, 2002
Posts: 1572
|
|
Howdy-- Good question... we discuss this a little on page 471. Here's the deal: inside <c:if>, for example, in the JSTL spec, it tells you that the attribute type of *test* is <rtexprvalue>true</rtexprvalue>. So... means it can be one of three things; * EL expressions ${whatever} * Scripting expressions <%= request.getAttribute("whatever") %> * <jsp:attribute> So, to answer your question, you CAN have more than just EL when the attribute type is defined as <rtexprvalue> (otherwise, it must be ONLY a static String value). So, that means that ANY place you see us using EL within an attribute value for a JSTL tag, you know that the rtexprvalue must be true, which means you can also use regular scripting expressions or a <jsp:attribute> in addition to EL. cheers, Kathy
|
 |
Nitish Bahadur
Ranch Hand
Joined: Aug 25, 2003
Posts: 118
|
|
I think we missed the $ in the test. <c:if test='${1 < 2}'> this is true. </c:if> <c:if test='${2 < 1}'> this is false. </c:if>
|
 |
 |
|
|
subject: c:if and c:choose
|
|
|