Samarland
Samarland

Reputation: 581

Exclude display one index from foreach list using jstl

I'm trying to not display on of my list that has a value

This code is displaying the whole list, and working correctly .

<li >                   
    <a href="javascript:viewAttachment('${documentName.value}', ${documentName.key}');">${documentName.key} </a>
</li>
</c:forEach>

That what I'm trying to do, but it's not working, I need to not display the file with name Asst Manual,

 <c:forEach items="${documentNames}" var="documentName" varStatus="status">
    <li ${status.last ? '' : 'style = "display:none"'}>
// don't display the file
            <c:if test="${documentName != 'Asst Manual' }" >
  <a href="javascript:viewAttachment('${documentName.value}', '${documentName.key}');">${documentName.key} </a>
</c:if>
    </li>
        </c:forEach>

It seemed to be not that hard,

Upvotes: 0

Views: 233

Answers (1)

GUISSOUMA Issam
GUISSOUMA Issam

Reputation: 2582

Make sure your condition is correct, you should use documentName.key and not the object documentName

<c:if test="${documentName.key != 'Asst Manual' }" >
  <a href="javascript:viewAttachment('${documentName.value}', '${documentName.key}');">${documentName.key} </a>
</c:if>

Upvotes: 1

Related Questions