Author | Message |
---|---|
e.laverdi
Posts: 15
|
Posted 13:11 Nov 05, 2009 |
Is formBackingObject necessary to get onSubmit to work? I decided to use handleRequestInternal to view the form but my submit button does not do anything. <bean name="/instructor/addOnlineAssignment.html" Am I missing anything in the bean? I have been staring at this page and for hours now and no progress. protected ModelAndView onSubmit( HttpServletRequest request, I right now I am not actually adding the online assignment. I just want to be able to redirect the success view. Any tips?
|
cysun
Posts: 2935
|
Posted 13:20 Nov 05, 2009 |
Make sure the form method is "post", not "get". The superclass SimpleFormController creates a backing object (i.e. command object) using the default (i.e. no argument) constructor of the command class specified in the bean specification. You don't need to override the formBackingObject method unless you want to create a command object in some other way. |
e.laverdi
Posts: 15
|
Posted 13:41 Nov 05, 2009 |
So the following should be enough to get me to the success view. I still dont understand why its not working hmmm. CONTROLLER protected ModelAndView onSubmit( HttpServletRequest request, XML <bean name="/instructor/addOnlineAssignment.html" JSP <form:form>
|
e.laverdi
Posts: 15
|
Posted 13:43 Nov 05, 2009 |
Form automatically adds the post method. |
jgreen
Posts: 23
|
Posted 14:20 Nov 05, 2009 |
Hey, I had that same problem for a while, where I would hit submit but nothing happens. Then I realized that I had to include <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> so that it would recognize the form:form tag. Just in case that helps... |
cysun
Posts: 2935
|
Posted 14:34 Nov 05, 2009 |
You shouldn't need to do that since the form tag lib is already included in WEB-INF/jsp/include/taglib.jspf, which you should include in your JSP. |
cysun
Posts: 2935
|
Posted 14:37 Nov 05, 2009 |
You should have the commandName and commandClass in the bean specification. Also add the command name to the <form> tag, i.e. <form:form commandName="...">. And do a "View Source" in your browser and see if the form is generated correctly. Add a logging statement in onSubmit to see if the controller received the post request. |
e.laverdi
Posts: 15
|
Posted 15:36 Nov 05, 2009 |
I seems like it kind find the OnlineAssignment class. Am I missing something? I checked the paths and are all correct. Attached is log XML <bean name="/instructor/addOnlineAssignment.html" CONTROLLER public ModelAndView handleRequestInternal( HttpServletRequest request, JSP <form:form commandName="onlineAssignment"> Last edited by e.laverdi at
15:37 Nov 05, 2009.
|
cysun
Posts: 2935
|
Posted 15:42 Nov 05, 2009 |
Does your OnlineAssignment class has a zero-argument constructor? |
e.laverdi
Posts: 15
|
Posted 15:55 Nov 05, 2009 |
Yes it does. |
cysun
Posts: 2935
|
Posted 16:58 Nov 05, 2009 |
Then try overriding the formBackingObject method. |
e.laverdi
Posts: 15
|
Posted 17:11 Nov 05, 2009 |
Will do try that |
cysun
Posts: 2935
|
Posted 17:18 Nov 05, 2009 |
OK, I know what's going on. Your handleRequestInternal() returns a view directly, thus bypasses the superclass's formBackingObject(). You should set "section" as a request parameter, then return "super.handleRequestInternal( request, response )". See TakeSurveyController for a properly written handleRequestInternal(). Also note that the access modifier for handleRequestInternal() should be protected, not public. Be careful with method signatures, or use the annotation @Override to make sure that you are actually overriding a superclass method, not creating a new one. |
e.laverdi
Posts: 15
|
Posted 17:36 Nov 05, 2009 |
Thank you will try that |