Hi,
I am trying to understand if I am going about it incorrectly.
I have a page: myPage.jsp, which I get to through Spring. Initially, the page is not supposed to have any data in it - just a form with two drop-downs that you can submit, and then, based on what you chose in the form, the same page will display data populated tables under the form.
The controller which handles the initial display of the page looks roughly like this in code:
the problem that I see is that when the page is displayed initially, I got to onSubmit() from showForm(), and command is null. So I have to call formBackingObject from onSubmit(). This is turning very convoluted: calling onSubmit() from showForm(), and formBackingObject() from onSubmit().Code:public class MyController extends SimpleFormController { private MyHelper helper; public void setHelper(MyHelper newHelper) { helper = newHelper; } public MyHelper getHelper() { return helper; } protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) { MyForm formObject = (MyForm ) command; ModelAndView mav = new ModelAndView(getSuccessView()); return mav; } protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors, Map controlModel) { return onSubmit(request,response,null,errors); } protected Object formBackingObject(HttpServletRequest request) { MyForm pageForm = new MyForm (); String param1= request.getParameter("param1"); String param2= request.getParameter("param2"); pageForm .setParam1(param1); pageForm .setParam2(param2); return pageForm ; } }
Am I not writing correct code? It just feels like there are things Spring would do for me without the need for cross-calling methods.


Reply With Quote
