You have to have a single model attribute per form. So, if your view contains a single form, you will need to have a "wrapper" object to pass to that form as its model. That's perfectly fine to have a UI-specific command object that nests several domain objects.
However, when appropriate, one may also easily create a single view with multiple forms, where each form would use its own model attribute. For that you can do the following:
Code:
<form:form id="form1" modelAttribute="cmdObjectOne">
...
</form:form>
<form:form id="form2" modelAttribute="cmdObjectTwo">
...
</form:form>
Have your controller (request handler methods) properly populate the Model with the instances for all the necessary model attribute objects. For example:
Code:
public ModelAndView something(...) {
ModelAndView mv = new ModelAndView("myview");
... // do whatever the handler needs to do
mv.addObject("cmdObjectOne", new CommandObjectOne());
mv.addObject("cmdObjectTwo", new CommandObjectTwo());
return mv; // return view with two model attributes for 2 forms
}
HTH,
Constantine

Originally Posted by
springflan
I have a registration page which asks for both Company and User details including password verification.
In the application I have a separate Company bean and a User bean.
Using the Spring form tags library it seems I can only create a form in the .jsp file as either
<form:form commandName="User">
or
<form:form commandName="Company">
So is it true that if I want to use the form tag library I can only have binding to a single domain model (User or Company), or else I need to create a super Bean UserCompany and use this for the domain model ?
Is there another nice solution for this that includes binding ?
Thanks for any help.