Skip to content

invalid doSubmit method executed for SimpleFormController [SPR-794] #5521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Mar 17, 2005 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket)

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 17, 2005

Mike Zupper opened SPR-794 and commented

Here is the scenerio:

  • MyAccountForm extends SimpleFormController
  • MyAccountValidator implements Validator

Within MyAccountForm I override the following method:

protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException errors)
throws Exception

with proper validation and no errors, The framework should call the "onSubmit" method with the defined signature but it does not. If I override, the following method:

protected ModelAndView onSubmit(Object command)
throws Exception


it calls the "onSubmit" method properly.

I need to access the HTTP request to set session data.

I used my IDE's debugger to trace it down and I could not find any reason why that above onSubmit method does not work... Any Ideas????

Please see issue# #5420 for similar problem.

Thanks,

Mike Zupper (mzupper@boscovs.com)


Affects: 1.1.3, 1.1.4, 1.1.5

Attachments:

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Mike Zupper commented

this method:
/**

  • Submit callback with all parameters. Called in case of submit without errors
  • reported by the registered validator, or on every submit if no validator.
  • <p>Default implementation delegates to onSubmit(Object, BindException).
  • For simply performing a submit action and rendering the specified success view,
  • consider implementing doSubmitAction rather than an onSubmit version.
  • <p>Subclasses can override this to provide custom submission handling like storing
  • the object to the database. Implementations can also perform custom validation and
  • call showForm to return to the form. Do <i>not</i> implement multiple onSubmit
  • methods: In that case, just this method will be called by the controller.
  • <p>Call <code>errors.getModel()</code> to populate the ModelAndView model
  • with the command and the Errors instance, under the specified command name,
  • as expected by the "spring:bind" tag.
  • @param request current servlet request
  • @param response current servlet response
  • @param command form object with request parameters bound onto it
  • @param errors Errors instance without errors (subclass can add errors if it wants to)
  • @return the prepared model and view, or null
  • @throws Exception in case of errors
  • @see #onSubmit(Object, BindException)
  • @see #doSubmitAction
  • @see #showForm
  • @see org.springframework.validation.Errors
  • @see org.springframework.validation.BindException#getModel
    */
    protected ModelAndView onSubmit(
    HttpServletRequest request, HttpServletResponse response, Object command, BindException errors)
    throws Exception {
    return onSubmit(command, errors);
    }

causes the problem: see the attached file.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Sorry, I have no clue what kind of misbehavior you're experiencing here. SimpleFormController simply delegates through the onSubmit chain from the version with all arguments down to the version with a single argument. This has been that way for a long time and has always worked, so I suspect that some side effect is happening in your case. Could you try to isolate the problem and submit a reproducible test case?

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

See the comments on the linked issue. A likely cause is that you imported the wrong BindException class: it needs to be org.springframework.validation.BindException, not java.net.BindException. If the wrong class is used in the method signature, the method doesn't actually override the one in the superclass, and thus won't be called...

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket)
Projects
None yet
Development

No branches or pull requests

2 participants