javaspringspring-mvcspring-webflowsakai

commandClass setter methods are not invoked while implementing SimpleFormController in spring 3.x


commandClass setter methods are not invoked while implementing SimpleFormController in spring 3.x, Calling getter method on command odject returns null value.

** bean configuration in xml file**

<bean id="uploadMessageBundleController" class="org.sakaiproject.adminmessagebundle.tool.UploadMessageBundleController">
            <property name="messageBundleService"><ref bean="org.sakaiproject.messagebundle.api.MessageBundleService"/></property>
            <property name="commandClass" value="org.sakaiproject.adminmessagebundle.tool.FileUploadBean"/>
            <property name="commandName" value="command"/>
            <property name="formView" value="uploadMessageBundle"/>
            <property name="successView" value="redirect:messageBundleHome.htm"/>
        </bean>

Solution

  • I have missed following bean definition in .xml file, so it was unable to call setter method in commandClass for file uploaded in the form.

    <bean id="multipartResolver"
            class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />