Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4865

Struts s:checkbox conversion fails to List<Integer>

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.5.13
    • Fix Version/s: 2.5.x
    • Component/s: Core, Core Tags
    • Labels:
      None

      Description

      Struts <s:checkbox> is not converted correctly to List<Integer> when only one checkbox element is present and checkbox is not checked.

      [Given]
      1) Mapping s:checkbox to a List<Integer>
      2) there is only one checkbox in the list
      3) the checkbox is not checked when the form is submitted.

      [Result]
      Input invalid

      The issue is caused by the checkbox tag using the "submit unchecked values" design pattern. As a result, the code base tries to convert the value of the single unchecked element to false (rather than not setting any value of the List<Integer>).

      Fix: Allow the developer to choose if the "submit unchecked values" is to be implemented. Add a new parameter to the s:checkbox tag ("requiredValue"). Default of requiredValue=true for backwards compatibility. When set to false, no hidden input values will be displayed in the view. This flexibility might be needed in other scenarios as well.

      Pull Request: https://github.com/apache/struts/pull/169

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              burtonrhodes Burton Rhodes
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified