Announcement Announcement Module
Collapse
No announcement yet.
Binding form with two or more Models Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binding form with two or more Models

    My Controller has 3 Domain Classes (Models): Department, Sector and Line.

    My doubt is how create a form with this 3 models?

    In JSP in form with 1 model I have a code like below:

    <form:form commandName="department">

    And Sector and Line? How to link with this form?

    Other question is about form too. Is possible use forms without involving a Model?

  • #2
    Create a command object composed of your domain objects like so:
    Code:
    class Command {
      Department department;
      Sector sector;
      Line line;
    
      // Getters and setters go here
    }
    All the form tags should be prefixed then with the name of the respective domain object, of course.

    HTH

    Comment


    • #3
      Hi F.Degenaar, thanks for your answer.

      I'm currently doing so, but wondered if there is another way.

      I wish doing this through with Spring MVC.

      Comment


      • #4
        There is an improvement request in jira regarding this -but with low priority. Seems to be added in 3.1.

        http://jira.springframework.org/browse/SPR-5025

        Comment

        Working...
        X