1

I'm trying to create a table, where when the "key" is equal to "name", the value is a link to another page otherwise it should print the value as text.I have the following keys: [name, category, schema]. It's an ArrayList

<c:when test='#{(results.keys.get(loopVal.index)).equals("name")}'>

In my table the column "name" should have values as a link. But it doesn't work, as if the c:when returns false. But i checked "results.keys.get(loopVal.index)" and it prints the keys correctly.

I have tried comparing with equals(), with ==, and eq. I also have the correct jstl library xmlns:c="http://java.sun.com/jsp/jstl/core"

I can't find the problem, maybe it has something to do with comparing a list element? or am I overlooking something really obvious?

Here is a larger snippet of my code:

<ui:repeat value="#{results.keys}" var="key" varStatus="loopVal">
                <td id="#{results.keys.get(loopVal.index)}_#{instance.getId()}" class="view">
                <c:choose>
                    <c:when test='#{(results.keys.get(loopVal.index)).equals("name")}'>
                        <h:link value="#{values.get(loopVal.index)}" outcome="search">
                        <f:param name="type" value="#{values.get(loopVal.index)}" />
                    </h:link>
                    </c:when>
                    <c:otherwise>
                        #{values.get(loopVal.index)}
                    </c:otherwise>
                </c:choose>
                </td>
            </ui:repeat>
noOne
  • 60
  • 1
  • 9

1 Answers1

1

You should use c:forEach instead of ui:repeat:

<c:forEach items="#{results.keys}" var="key" varStatus="loopVal">
...
</c:forEach>

Have a look at this post by BalusC about the difference between tag handlers (like c:forEach) and normal JSF components (like ui:repeat).

user1983983
  • 4,793
  • 2
  • 15
  • 24