user762532
user762532

Reputation: 140

Spring property editor doesn't work

I've come to spring from jsf, and I'm new in this,,, I want to have a converter for my IdField class,,, I did some research and wrote my own property editor,,,

public class IdFieldPropertyEditor extends PropertyEditorSupport {

and I registered it in dispatcher-servlet.xml

<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
    <property name="customEditors">
        <map>
            <entry key="com.example.IdField">
                <bean class="com.example.IdFieldPropertyEditor" />
            </entry>
        </map>
    </property>
</bean>

so , as I understood these steps are enough, but I still get an error like cannon convert from String to IdField,,,

can anyone help to understand what steps I missed? Thanks,,,

Upvotes: 1

Views: 626

Answers (1)

axtavt
axtavt

Reputation: 242686

CustomEditorConfigurer has nothing to do with Spring MVC, it configures property editors for interpreting values in XML config files.

To configure property editors for specific controller, use @InitBinder-annotated method. To do it globally for all controllers, use custom WebBindingInitializer. See 15.3.2.12 Customizing WebDataBinder initialization.

Upvotes: 3

Related Questions