Checkbox/RadioButton incorrectly converts collections of enums with a custom converter [SPR-16082] #20631
If you have an a collection of enums, for which you have implemented a custom org.springframework.core.convert.converter.Converter, the values are mapped from the form differently then they are mapped back to it. When spring reads the values from a submitted form, it runs the value supplied to the tag through the conversionService, so it expects the values to be in the checkbox/radiobox value field that the converter recognizes. However, when checking if the checkbox/radio button should be checked, it requires the value of the box to match the name() method of the enum, and does not run through the converter when checking for "equality' to mark the correct boxes checked. The issue seems to lie in org.springframework.web.servlet.tags.form.SelectedValueComparator.exhaustiveCompare(Object, Object, PropertyEditor, Map<PropertyEditor, Object>)
The logic first checks if the class we are binding to is an enum, and if it does, it checks against the toString of the enum. If that doesn't match, it then returns, skipping the PE compare later on, which would use the conversion service to properly convert the string to the appropriate type.
Basically, the else before the PE-Based comparison should be removed, to the conversion service always gets a chance to convert before the comparison
Backported to: 4.3.13