Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

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

 
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.
 
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.
 
yeah, but ... what would PIE do? Especially concerning this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!