1

I'm using Spring with dijit components to render an option list from an enum in my model:

<form:select path="selection">
                <form:option value="" label="Please select"></form:option>
                <form:options></form:options>
                </form:select>
                <noscript>
                    <button id="btnSelect" type="submit" name="_eventId_dropDownSelectionChange">Select</button>
                </noscript>
                <script type="text/javascript">
                    Spring.addDecoration(new Spring.ElementDecoration({
                        elementId : "selection",
                        widgetType : "dijit.form.Select",
                        widgetAttrs : {
                            forceWidth : true,
                            missingMessage : "<s:message code="NotEmpty" />"
                        }
                    }));
                    Spring.addDecoration(new Spring.AjaxEventDecoration({
                        elementId : "selection",
                        formId : "templateModel",
                        event : "onChange",
                        params : {  _eventId: "dropDownSelectionChange" }
                    }));
                </script>

When Javascript is off, the post from btnSelect successfully converts the selected item to an enum on the server side. That is, my conversion service shows this message:

DEBUG: org.springframework.binding.mapping.impl.DefaultMapping - Adding mapping result [Success@15fddb33 mapping = parameter:'selection' -> selection, code = 'success', error = false, originalValue = 'IPSUM', mappedValue = 'IPSUM']

However, when Javascript is on and the post goes over XHR, the enum conversion fails. Conversion service showing this message:

DEBUG: org.springframework.binding.mapping.impl.DefaultMapping - Adding mapping result [TargetAccessError@7b7d8769 mapping = parameter:'selection' -> selection, code = 'typeMismatch', error = true, errorCause = org.springframework.binding.expression.ValueCoercionException: Value could not be converted to target class; is a suitable type converter registered?, originalValue = 'selection', mappedValue = [null]]

I don't understand why this is happening if they're both using the same conversion service. Do I have to set up a special configuration so that AJAX calls can bind to enums?

mental_wao
  • 11
  • 1
  • 3

0 Answers0