Announcement Announcement Module
Collapse
No announcement yet.
SimpleFormController - command object has no data Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleFormController - command object has no data

    I am using spring's SimpleFormController and html form tags in the view html.
    I don't get any data in command object of the onsubmit method of my controller.

    If I try to do request.getParameter(anyFormfieldname) I see that the values are there but don't know why the commad object does not have this data ? Am I missing something ?

    here's my configuration -

    <entry key="/**/MyTest.do">
    <ref local="MyController"/>
    </entry>

    <bean id="MyController" class="com.MyController">
    <property name="dataService">
    <ref bean="myDataService"/></property>
    <property name= "commandClass">
    <value>com.myFormBean</value></property>
    <property name="commandName" value="myForm"/>
    <property name="successView"><value>MyViewInfo</value></property>
    </bean>


    Here's the view --

    <form id="myForm" name="myForm" action="MyTest.do" method="post">
    FirstName :<input type="text" name="myForm.firstName" value="AAA"/>
    LastName :<input type="text" name="myForm.lastName" value="BBB"/>
    <input type="submit" name="myForm.submitButton" id="myForm.submitButton" value="submit" />
    </form>


    my controller overrides the onSubmit method -

    public class TestController extends SimpleFormController {
    protected ModelAndView onSubmit(HttpServletRequest request,
    HttpServletResponse response,
    Object commandObject, BindException exception) {
    ..
    }
    }


    Thanks.

  • #2
    You need to bind the field with the domain object properties. You'll need to do this by adding the Spring form tags to your jsp-page. See documentation and examples.

    Comment


    • #3
      Thanks for you reply.
      I am not using JSPs, I am using HTML and velocity. Is there a way I can get it working with html form tags ?

      Comment


      • #4
        Don't know about velocity except what it's for...

        Comment

        Working...
        X