How to display user_name
and user_id
inside th:title.
HTML
<div class="ui-widget tooltip-wrapper" data-toggle="tooltip" data-placement="right" th:title="*{user_id} + ${'-' + creator.user_name}" > </div>
I need to check whether user_id
is not null and also user_name
is not null and display both in tool tip.
Sample : 101 - Janet
I tried with th:title="*{user_id!=null} + ${'-' + creator.user_name}"
.
But it is displaying as true
instead of the actual value.
Currently if the value is null, it is displaying as null
in tooltip. But I don't want to display if the value is null or empty.
Can anyone help on this. Thanks.
Try this
th:title="*{user_id?:''} + '-' +${creator.user_name?: ''}"
You can find more about conditional operator & Elvis operator on documentation.