1

I try to set value on a list which depends on that if a map (which I redirect from spring controller) contains key which is an user id. My code looks like that:

<%@ page session="false"%>
<%@ taglib prefix="t" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

 <datatables:table id="users" url="${datasource}" serverParams="APP.datatables.helpers.extraParamsUsersList" serverSide="true" cssClass="appDataTable" autoWidth="false" stateSave="true" row="user" paginate="true" paginationType="full_numbers" info="false" filter="true" dom="plrtip" ext="columnFilterCallback" filterPlaceholder="none" displayLength="10">
     <!-- -->
     <c:set var="result" value="false"/>
     <c:forEach var="entry" items="${boxes}">                           
        <c:if test="${entry.key != user.id}">
            <c:set var="result" value="true"/>
        </c:if>
    </c:forEach>
    <c:if test="${result}">
        <!-- some code -->
    </c:if> 
</datatables:table>

The map isn't empty and contains keys of some users but result is always false. I checked that if is given real value of an user id (e.g. 1) then I get correct result. Do you have any idea what I do wrong?

joamor
  • 31
  • 6

1 Answers1

0
<c:if test="${entry.key != user.id}">

Surely you mean

<c:if test="${entry.key == user.id}">

But you don't need to iterate the map. Just use containsKey().

user207421
  • 305,947
  • 44
  • 307
  • 483
  • Yes, I added wrong version of my condition but still it doesn't work. I'm sorry. I had tried with `containsKey()` and other solutions (and I checked it once again a moment ago) before I wrote here but it always return false. – joamor Apr 12 '17 at 05:24