• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Spring MVC Form Checkbox vs Checkboxes

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am facing strange problem with form:checkbox attribute in my Spring MVC form. I am trying to display and edit checkbox values and I don't understand why "form:checkboxes" is working and "form:checkbox" is not.

Here is my code:


The result page screenshot is attached. First checkbox is working, the second one in forEach is not checked and I do not why.


Am I doing anything wrong?
Unfortunately I have to use checkbox with forEach to add more elements.

I am using Spring version 5.1.9.RELEASE

Any advice is appreciated!
Sni-mek-obrazovky-2021-02-18-v-17.44.41.png
[Thumbnail for Sni-mek-obrazovky-2021-02-18-v-17.44.41.png]
 
Bartender
Posts: 2266
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not familiar with Spring MVC form.
But one experiment you can first try is to replace the forEach by multiple checkbox, like this example:
https://mkyong.com/spring-mvc/spring-mvc-checkbox-and-checkboxes-example/
 
Mick Common
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replay, I already tried "checkboxes" element and it is written in my post, this approach works! Unfortunately I need to use checkbox inside forEach to add more elements.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic