ModelAndView onsubmit(...)
Hi all,
I have a JSP page and i am using the SimpleFormController.
the onSubmit(...) method only gives me one Object command.
But what if my form in the JSP page should result in two different JavaBeans(POJO's), how would i implement that in the in my formController that implements the onSubmit method.
Best Regards
Cemil Özdemir
One solution is that you should put two JavaBeans into your current CommandObject then in onSubmit you can modify those two JavaBean
Originally Posted by shoaOne solution is that you should put two JavaBeans into your current CommandObject then in onSubmit you can modify those two JavaBean
Thanks for the answer.
That is also what i want to do, but how to do it.
Because normally you can only do something like this:
protected ModelAndView onSubmit(fromServletRequest request, fromServletResponse response, Object command, BindException errors) throws Exception { PriorityPolicy priorityPolicy = (PriorityPolicy) command;
priorityPolicyService.saveObject(priorityPolicy)
}
So you retrieve only one object.
How do i bind two objects to the command object, and retrieve them ?
Hope you can help.
Best Regards
Cemil
You can do something like:
class MyCommand { PriorityPolicy priorityPolicy; NotPriorityPolicy notPriorityPolicy; ...
public PriorityPolicy getPriorityPolicy(){ ... }
}
Then
protected ModelAndView onSubmit(fromServletRequest request, fromServletResponse response, Object command, BindException errors)
throws Exception { MyCommand cmd = (MyCommand) command; PriorityPolicy priorityPolicy = cmd.getPriorityPolicy(); priorityPolicyService.saveObject(priorityPolicy) ....
}
In jsp you can bind:
myCommand.priorityPolicy.name
myCommand.notPriorityPolicy.name
...
Thanks,
Appreicate youre help.
I got a bit further now.
Best Regards Cemil |