| Author |
EL JSTL if test syntax
|
Mitch Young
Greenhorn
Joined: Dec 15, 2006
Posts: 10
|
|
Hi All,
I an having problems comparing the string value of a bean property with another string passed into the jsp as a param using EL and a c:forEach loop.
I have an ArrayList of beans that holds menu items. I'm using a c:forEach to loop through all the beans in the array and only display the ones that have a category property value that matches the param value from the previous page.
<c:forEach var="cm" items="${cacheMenu}" > // ArrayList of MenuBeans
// I have tried all the following :
// cat is the category type like Pizza
<c:if test="${cm.category eq param.cat}">
<c:if test="${cm.category == param.cat}">
<c:if test="${cm.category == 'Pizza'}">
<c:if test="${cm.category == '<%=cat%>'}">
<c:if test="${cm.category eq param.cat}">
<c:if test="${cm[category] eq param.cat}">
<c:if test="${cm['category'] eq param.cat}">
and even more...
<tr>
<td>${cm.category}</td>
<td >${cm.item} <input input="text" size="2" value=""/></td>
<td>${cm.description}</td>
<td>${cm.size}</td>
<td>${cm.price} <input type="hidden"/></td>
</tr>
</c:if>
</c:forEach>
If I use <c:if test="${cm.category != null}.
It prints all the MenuBeans in the list so I know it's the syntax of the if test that's wrong.
Thanks much.">
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
|
Have you definitively verified that cm.category and param.cat contain the exact same string including case and whitespace?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Mitch Young
Greenhorn
Joined: Dec 15, 2006
Posts: 10
|
|
Thanks Bear,
That was it, whitespace (Duhh).
|
 |
 |
|
|
subject: EL JSTL if test syntax
|
|
|