Reputation: 2056
I have a template where I want apply some conditions to show 1 icon or another, but no icon is showed, I only see the text (true, false) in the cell
<tr th:each="systemAlarm : ${systemAlarms}">
<td class="col_description" th:text="${systemAlarm.description}" ></td><!-- ID -->
<td class="col_name" th:text="${systemAlarm.enabled}">
<span th:if="${systemAlarm.enabled}" >
yes<i class="fa fa-bullseye fa-2x" style="color:green; text-align: center;" aria-hidden="true"></i>
</span>
<span th:if="${!systemAlarm.enabled}">
no<i class="fa fa-bullseye fa-2x" style="text-align: center;" aria-hidden="true"></i>
</span>
</td><!-- NAME -->
</tr>
Upvotes: 0
Views: 2453
Reputation: 20477
In your original html, you have:
<td class="col_name" th:text="${systemAlarm.enabled}">
the th:text
attribute overwrites the contents of that <td>
-- which includes the html for the icons. You need to remove it. So, it should look like this:
<tr th:each="systemAlarm: ${systemAlarms}">
<td class="col_description" th:text="${systemAlarm.description}" />
<td class="col_name">
<span th:if="${systemAlarm.enabled}">
yes<i class="fa fa-bullseye fa-2x" style="color:green; text-align: center;" aria-hidden="true"></i>
</span>
<span th:if="${!systemAlarm.enabled}">
no<i class="fa fa-bullseye fa-2x" style="text-align: center;" aria-hidden="true"></i>
</span>
</td>
</tr>
Upvotes: 2