samedi 24 décembre 2016

If..Else in thymeleaf within tags for TagIt

I have a problem. I want to show the list of interests of a user (or an example when the user has none). I need to use li tags for my TAG-IT library to take care of them. That is a must!

So I did an IF in thymeleaf that I need to mix with a li tag in a div. It shows a bunch of bullets (list of interests) for TAG-IT library to show them as a users' tags. But when the users has no tags attached, I have another IF to the show the tag with a message.

I thought my solution should work but the result is that it shows the interests from the user, but also the one that should only be shown when the user is new (and has no interests registered yet). It is like the second IF is not working and is always shown.

<div id="interestDiv">
<ul id="interestList">
    <li th:if="${interest} != null" th:each="interest : ${profile.interests}" th:text="${interest.name}">ID data</li>
    <li th:if="${interest} == null" th:text="'add your interest here (example: music ! )'">ID data</li>
</ul>

Aucun commentaire:

Enregistrer un commentaire