Announcement Announcement Module
Collapse
No announcement yet.
why it doesn't call onSubmit() method?? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • why it doesn't call onSubmit() method??

    Hi,
    My controller extends SimpleFormController and override onSubmit()method.when i request , it does not call ModelAndView onSubmit() method.i
    have try every signature for onSubmit() method .
    but when My controller implements Controller and orerride handleRequest() method ,it works well.But according to my requirment i need to call ModelAndView onSubmit()method .
    Could you tell me a way to get me out?
    Thanks.
    Last edited by zhoujingchun2004; Feb 6th, 2006, 09:04 PM.

  • #2
    Originally posted by zhoujingchun2004
    but when My controller extends Controller and orerride handleRequest() method
    Hmm, you should probably *not* be overridding the handleRequest method.

    It is actually the code within handleRequest that executes the workflow, which eventually ends in onSubmit being called. BTW; within SFC the various methods of onSubmit simply delegate to a narrower method, i.e. onSubmit(.lots of arguments) calls onSubmit(fewer arguments) which finally calls onSubmit(Object), so be careful if you override more than one by accident.

    Anyways; onSubmit won't be called if there are binding, or validation issues. You won't always see the error if it is a binding error, so use the "http://www.springframework.org/docs/api/org/springframework/web/servlet/tags/BindErrorsTag.html" to see all the errors.

    Comment


    • #3
      Originally posted by yatesco
      so be careful if you override more than one by accident.
      thanks yatesco's answer.now ,my controller override one onSubmit() method.the siganature is onSubmit(request,response, command,errors).but it doesn't work yet.And the formcontroller is redirecting to the form view 。
      Last edited by zhoujingchun2004; Feb 6th, 2006, 09:28 PM.

      Comment


      • #4
        It is resovled now.Because i'm not doing a POST.only by entering the request url in browser.In this case,you can override isFormSubmission() method ,then you can call the onSubmit() method.
        Last edited by zhoujingchun2004; Feb 7th, 2006, 01:16 AM.

        Comment


        • #5
          Originally posted by zhoujingchun2004
          IBecause i'm not doing a POST.only by entering the request url in browser.
          Yes, by default the SimpleFormController treats a GET as a request to render the form, a POST as a request to submit data.

          This is fairly standard HTTP usage though

          And yes; overridding isFormSubmission will work fine.

          Comment


          • #6
            If you have to override isFormSubmission() for a SimpleFormController, it sounds to me like you have picked the wrong Controller. Are you actually submitting form input to this Controller?

            Comment


            • #7
              Originally posted by martinl
              If you have to override isFormSubmission() for a SimpleFormController, it sounds to me like you have picked the wrong Controller. Are you actually submitting form input to this Controller?
              I disagree

              For example, we have developed a search which accepts both GET and POST parameters, i.e.:

              Code:
              search.htm?criteria=xyz
              is to be treated exactly the same as:

              Code:
              <form ... action="search.htm" method="POST"...>
                <input type="text" name="criteria" value="xyz"/>
              </form>
              SFC is absolutely the right thing, and we require binding on both GET and POST

              Comment


              • #8
                Good point. There are, of course, use cases where overriding isFormSubmission() is the right thing.

                Comment

                Working...
                X