Issue
In my case, the condition is if the question.objQuestion.questionContent
is null, show the question.sbjQuestion.questionContent
. My attempt is shown at below. But it doesn't work.
<td th:switch = "${question.objQuestion.questionContent}">
<span th:case="${question.objQuestion.questionContent == null}" th:text = "${question.objQuestion.questionContent}"></span>
<span th:case="${question.objQuestion.questionContent != null}" th:text ="${question.sbjQuestion.questionContent}"></span>
</td>
obj_question_id
and sbj_question_id
are foregin id
Solution
It works when I use the Elvis Operator ?
in this way
The solution is attached at below:
<td>
<span th:text = "${question.objQuestion?.questionContent}"></span>
<span th:text = "${question.sbjQuestion?.questionContent}"></span>
</td>
Answered By - mike kong
Answer Checked By - Terry (JavaFixing Volunteer)