0

I have a thymeleaf form and I would like to return a NULL value to my underlying controller instead of a blank String. Is there a way to do this directly in thymeleaf or do we have to set that conversion logic in the controller?

<div class="form-group"> <label for="note" class="formFieldTitle">Note</label> <textarea class="form-control" rows="4" id="note" placeholder="Note" th:field="*{note}" th:classappend="${validated == true ? (#fields.hasErrors('note') ? 'is-invalid' : 'is-valid') : ''}" th:attr="readonly=${#authorization.expression('!hasAuthority(''Edit Patients'')')}"> </textarea> <label class="errorMessage" th:if="${#fields.hasErrors('note')}" th:errors="*{note}">Note Error</label> </div> 
3
  • Does this answer your question? Using Thymeleaf when the value is null Commented Dec 23, 2019 at 22:18
  • Are you asking about after you are submitting the form (on POST)? Commented Dec 24, 2019 at 0:12
  • correct, when submitting the form i would like the field to have a NULL value as opposed to an empty string. The form is bean-backed and the entity is provided directly to the controller, which is why i'm not sure how to direct thymeleaf to provide a NULL value in the case of a field left blank. Commented Dec 24, 2019 at 1:54

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.