|
|
Hi everyone,
This is a somewhat unusual posting to the forum, but I am looking for Spring experts to be able to answer some questions about the framework for research purposes.
For reference: I am completing my PhD in software engineering, and my thesis research aims to make complex software frameworks, like Spring, easier to use. To validate that my system works, I have been going through the Spring forums to show that my system would have detected some of the problems and have made it possible for the poster to fix the problem on their own.
While I do have several working examples where my system correctly locates the problem described in a forum posting (yay!), there are two MVC issues that I don't understand, even after a lot of studying the sample programs, books, and tutorials.
I will post the two issues below, along with references to specific threads that mention them. Any help you can give me is much appreciated and will hopefully result in a research idea that is highly useful for industry.
Thanks,
Ciera Jaspan
Doctoral Candidate in Software Engineering
Carnegie Mellon University
I#8217;ve noticed several threads about SimpleFormController.onSubmit() where the poster has created a new HashMap to contain the model data rather than using errors.getModel(). It is my understanding that, in AbstractFormController and derived classes, errors.getModel() should be used because Spring has already populated it with the model data from calls to formBackingObject() and referenceData(). The only reason to create a new HashMap is when overriding a controller that is not an AbstractFormController (like Controller).
a) Is my understanding here correct? I#8217;ve had trouble verifying this since the books and tutorials talk very little about it beyond simple examples.
b) Given that AbstractFormController populates errors.getModel() based on the results from referenceData(), is there any reason to add additional entries to errors.getModel() in onSubmit()? Is it correct to say that all this work should have been done in referenceData() (except the formBackingObject, of course)?
Forum threads that reference this issue:
showthread.php?t=21751 (post 6)
showthread.php?t=28603 (post 2)
showthread.php?t=33456 (post 9)
showthread.php?t=39209 (post 4)
It is still not clear to me when it is appropriate to return showForm() from a call to onSubmit(), and when it is appropriate to return a new ModelAndView(). None of the books and tutorials I’ve read even mention the showForm() method.
a) Is it simply “preferred” to call showForm() because it is cleaner, or is it actually required in some circumstances for correct functionality?
b) Under what circumstances is it more appropriate to return showForm than it is to return a new ModelAndView()?
c) Under what circumstances is it more appropriate to return a new ModelAndView() than it is to return a showForm()?
d) Are the above circumstances different for the different versions of showForm?
Forum threads that reference this issue:
showthread.php?t=13320 (post 4)
showthread.php?t=33139 (post 2)
showthread.php?t=33168 (post 15)
showthread.php?t=36333 (post 2) (This is the only one that says not to use showForm, so clearly it is not correct everywhere) |
|