Results 1 to 9 of 9

Thread: onSubmit - Say it ain't so

  1. #1
    Join Date
    Jan 2005
    Location
    New Haven, CT USA
    Posts
    6

    Default onSubmit - Say it ain't so

    I am trying to implement the File Upload code example on page 138 (Version 1.2 RC2) of the reference documentation and have noticed that although the successview is reached after I submit the form, nothing within the onSubmit() method is processed. That is, no logger info is written and the file is not saved. How is this possible? I thought that if the successview is reached, the onSubmit() method must have been called. Since this is not happening, how can the successview be reached? How can it be skipped? Is it a configuration issue?

    I have another form that also exhibits this behavior, so I placed my processing code within the Validator, but am curious what could be causing the SimpleFormController to behave this way.

    I am using Spring 1.2RC2, and Tomcat 5.0.18, and lib files from the Spring distribution.

  2. #2
    Join Date
    Oct 2004
    Location
    Herndon, VA, US
    Posts
    648

    Default

    There are three overloaded versions of onSubmit. By default the version with the full parameter set calls a simpler one, which in turn calls the simplest one. Which one are you expecting to be called?

    Also sometimes it might be your overriding version isn't really overriding (e.g. mismatching signatures).
    --Jing Xue

  3. #3
    Join Date
    Jan 2005
    Location
    New Haven, CT USA
    Posts
    6

    Default

    I am using the one from the example. That is,

    protected ModelAndView onSubmit(
    HttpServletRequest request,
    HttpServletResponse response,
    Object command,
    BindException errors)
    throws ServletException, IOException { }

    The fact that the calls from within this method are not reached and yet a successview is returned is somewhat troubling. So how is it possible that a view is returned without the business logic being invoked? Again, this example is taken directly from the reference docs. I would be happy to send the war file to anyone who wants to observe the behavior.

  4. #4
    Join Date
    Jan 2005
    Location
    MD
    Posts
    31

    Default

    That is strange. Are any of the methods being invoked in your form controller. You could try overriding for example the formBackingObject or showForm methods to ensure your controller is being used for the post?

  5. #5
    Join Date
    Aug 2004
    Location
    Atlanta, GA
    Posts
    129

    Default

    Make sure your method is actually overriding the superclass method. That bit one of my team just today.
    Randy

  6. #6
    Join Date
    Jan 2005
    Location
    New Haven, CT USA
    Posts
    6

    Default

    None of the methods within the onSubmit are being invoked. The FormController is initialized but when the form is submitted only the view wired in the application context file is returned. If I need to invoke business logic I am forced to place it in the Validator. Although I am not opposed to this solution, the framework is not behaving as expected and thus I am concerned.

    rstearns01 - Could you elaborate a little more. How do I make sure the onSubmit is actually overriding the sperclass method, since this is essentially the problem. What could be missing that allows the successview to be returned, but does not perform any methods contained within the onSubmit()?

    Since it is apparent that a successview can be returned without any methods within the onSubmit() being invoked, another way of putting this issue is, what needs to be done to guarantee the correct behavior?

    Thanks.

  7. #7
    Join Date
    Apr 2005
    Location
    Guildford, UK
    Posts
    15

    Default

    I think what Randy means is check that the signature of your overriden method is exactly right...I too have spent many an unhappy hour trying to work out why overriden methods were not getting invoked - I now make sure to let my IDE (eclipse) generate method sigs for me (Ctrl-Space) !

    Neil
    Neil Canham
    Know Sense Limited
    ...sense from KnowSense

  8. #8
    Join Date
    Aug 2004
    Location
    Atlanta, GA
    Posts
    129

    Default

    Quote Originally Posted by fineman
    I think what Randy means is check that the signature of your overriden method is exactly right
    Precisely. Even if you copy/paste from somewhere else, you're not guaranteed it will override; especially if your class has already imported a class with the same name as in your signature, but a different package.

    Check your IDE (normally the right gutter). There should be a small icon informing you that the method is an override. If not, have your IDE generate it. If it is, double check your handler mapping is referencing the controller you think it is.

    HTH
    Randy

  9. #9
    Join Date
    Jan 2005
    Location
    New Haven, CT USA
    Posts
    6

    Default

    Thanks to everyone who responded to my problem.

    I went back to the API (RTFM) and discovered you were all correct. I had the response and request order reversed in the onSubmit(). I, as well, will have to create some eclipse templates to be sure to avoid this in the future.

    I sure appreciate your responses.

    George

Similar Threads

  1. redirect view after onSubmit
    By eg in forum Web
    Replies: 6
    Last Post: Apr 13th, 2007, 07:25 AM
  2. SimpleFormController not do onSubmit
    By heleno_alves in forum Web
    Replies: 2
    Last Post: Oct 18th, 2005, 07:22 AM
  3. using (request) in onsubmit
    By anieshuk in forum Web
    Replies: 1
    Last Post: Aug 3rd, 2005, 01:48 AM
  4. Forcing onSubmit to be called
    By biguniverse in forum Web
    Replies: 1
    Last Post: Aug 2nd, 2005, 01:54 PM
  5. Replies: 2
    Last Post: Jul 5th, 2005, 02:20 AM

Posting Permissions

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