• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

how to bind thymeleaf checkbox value to boolean variable in spring ?

 
Muztaba Hasanat
Ranch Hand
Posts: 50
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to bind checkbox value to spring bean as boolean. when use check the checkbox then it will take as true value otherwise false.

This is what I have done so far. I am using `Kotlin` as programming language and `Thymeleaf` with the html page.

html page


this is the bean,

this is the rest controller


the request is hit the controller successfully but how can I bind the value true when the checkbox is check and false otherwise.

Thanks in advance.
 
Luke Dutton
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One possible way would be to utilize javascript to change the value of the checkbox on click.
One other option is to utilize two different radio buttons and use the th:field="isPresent" option to specify that return attribute is named "isPresent".

I'm not sure if your stuff is working, but I don't see that you've assigned an object to your form. You can include th:object="AttendanceJson" in your 'form' HTML element.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!