title: Combobox is not populating after form validation fails - Spring 3 MVC
body: <p>I am using Spring mvc for my web application. I have a simple form with some textfields and combo-boxes. </p>
  
  <p><strong>Problem:</strong> I am submitting the form with null values and it performs the validation. Since the null values are there so validation shows the form again but with blank combo-boxes. When the form is displayed for the first time, everything works fine.</p>
  
  <p>Here is the code. How can I populate them with last selected values?</p>
  
  <p>VIEW FILE</p>
  
  <pre><code>&lt;form:form method="post" modelAttribute="screening"&gt;
  
  &lt;table&gt;
  &lt;!-- Text Form --&gt;
      &lt;tr&gt;
          &lt;td&gt;EPI ID&lt;/td&gt;
          &lt;td&gt;&lt;form:input path="epi_Id" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;form:errors path="epi_Id" cssClass="error" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;!-- Combo-Box --&gt;
          &lt;td&gt;Enrollment Center&lt;/td&gt;            
          &lt;td&gt;
              &lt;form:select path="enrollmentCenter"&gt;
              &lt;form:options items="${epiCentersList}" itemValue="centerID" itemLabel="name"/&gt;
              &lt;/form:select&gt;
          &lt;/td&gt;
  
          &lt;td&gt;&lt;form:errors path="enrollmentCenter" cssClass="error" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
          &lt;td colspan="3"&gt;&lt;input type="submit" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;/form:form&gt;
  </code></pre>
  
  <p>CONTROLLER</p>
  
  <pre><code>@Controller
  @RequestMapping("/ScreeningForm")
  @SessionAttributes("screening")
  
  public class ScreeningFormController {
  
  @RequestMapping(method=RequestMethod.GET)
  public String setupForm(Model model)
  {
      ScreeningDomain screen=new ScreeningDomain();
      model.addAttribute("screening", screen);        
      model.addAttribute("epiCentersList", usc.getAllEpiCentersList());
      return "ScreeningForm";
  }
  
  @RequestMapping(method=RequestMethod.POST)
  public String submitForm(@ModelAttribute("screening") ScreeningDomain screeningDomain, BindingResult result, SessionStatus status)
  {
      ScreeningServiceImpl screenService = new ScreeningServiceImpl();
      screeningValidator.validate(screeningDomain, result);
      if (result.hasErrors())
      {
          UtilityServiceClass usc=new UtilityServiceClass();
          model.addAttribute("epiCentersList", usc.getAllEpiCentersList());
          model.addAttribute("screening", screeningDomain);
          return "ScreeningForm";
      }
      else
      {
          screenService.add(screeningDomain);
          return "redirect:ScreeningForm";
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Everything else is working fine.
  I thing model is loosing list object <strong>"epiCentersList"</strong> values but I cant figure out why.</p>