Results 1 to 4 of 4

Thread: SimpleFormController - command object has no data

  1. #1
    Join Date
    Sep 2008
    Posts
    4

    Default 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. #2
    Join Date
    Apr 2005
    Location
    Finland
    Posts
    314

    Default

    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.
    if a trainstation is where the train stops, what's a workstation...

  3. #3
    Join Date
    Sep 2008
    Posts
    4

    Default

    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 ?

  4. #4
    Join Date
    Apr 2005
    Location
    Finland
    Posts
    314

    Default

    Don't know about velocity except what it's for...
    if a trainstation is where the train stops, what's a workstation...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •