title: Spring MVC. Populating dropdown list from different objects
body: <p>Here is tricky issue, I have next jspx:</p>
  
  <pre><code>&lt;form:form modelAttribute="employee" id="employeeUpdateForm" method="post"&gt;
      &lt;form:select path="departmentId"&gt;           
      &lt;form:options items="${departments}" /&gt;
  &lt;/form:select&gt;
  
  &lt;button type="submit"&gt;Save&lt;/button&gt;
      &lt;button type="reset"&gt;Reset&lt;/button&gt;
  &lt;/form:form&gt;
  </code></pre>
  
  <p>and my updateForm method:</p>
  
  <pre><code>@RequestMapping(value = "/{id}", params = "form", method = RequestMethod.GET) 
  public String updateForm(@PathVariable ("id") Long id, Model uiModel) { 
  uiModel.addAttribute("employee", employeeService.findById(id));
  
  List&lt;Department&gt; departments = employeeService.getAllDepartments();
  uiModel.addAttribute("department", departments);
  
  return "staff/update";
  }
  </code></pre>
  
  <p>"department"  has two fields: departmentId (int) and divisionName (String).</p>
  
  <p>So, "employee" and "department" are two different objects, I would like to have ability to populate field related to "employee" (departmentId) with string representations from "department". Their departmentId match one another. Once certain department is chosen its id is putting to employee.departmentId.</p>
  
  <p>Thanks in advance!</p>