Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-5354

Binding doesn't work when no radio button in a set is selected

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Waiting for Triage
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Per http://static.springframework.org/spring/docs/2.5.x/reference/view.html#view-jsp-formtaglib-checkboxtag

      "What you might not expect to see is the additional hidden field after each checkbox. When a checkbox in an HTML page is not checked, its value will not be sent to the server as part of the HTTP request parameters once the form is submitted, so we need a workaround for this quirk in HTML in order for Spring form data binding to work. The checkbox tag follows the existing Spring convention of including a hidden parameter prefixed by an underscore ("_") for each checkbox. By doing this, you are effectively telling Spring that " the checkbox was visible in the form and I want my object to which the form data will be bound to reflect the state of the checkbox no matter what "."

      In HTML, radio buttons behave in the same way - if none of them are selected, the server gets nothing. But unlike checkboxes, Spring isn't adding this workaround for radio buttons.

        Attachments

          Activity

            People

            • Assignee:
              rstoya05-aop Rossen Stoyanchev
              Reporter:
              np Jason Barnabe
              Last updater:
              Chris Beams
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                5 years, 23 weeks, 2 days ago