Results 1 to 4 of 4

Thread: Binding form with two or more Models

  1. #1
    Join Date
    Jan 2010
    Posts
    13

    Default 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. #2
    Join Date
    May 2005
    Posts
    288

    Default

    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

  3. #3
    Join Date
    Jan 2010
    Posts
    13

    Default

    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.

  4. #4
    Join Date
    Nov 2005
    Posts
    114

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •