title: Spring MVC - Drop Down Object Selection - No primary identifier
body: <p>A fairly common use case occurs where there is a list of Java objects, from which selections can be made on a web form - usually you'd use the primary key of the object as the value so that the controller could either do a lookup, or just bind the key to whichever object is created/updated.</p>
  
  <p>My problem is that the list to choose from are not persistent, keyed objects, they are business models from a service which have no reasonable way to retrieve them based on the data contained.  Below is some psuedo code where a list of Foo's are given to the page, and we can easily communicate to the controller onSubmit the name of Foo, but what if there are other fields of Foo that need to be submitted?</p>
  
  <p>controller:</p>
  
  <pre><code>referenceData() {
      ...
      List foos = fooService.getFoosForBar( bar )
      return { 'foos', foos }
  }
  </code></pre>
  
  <p>jsp:</p>
  
  <pre><code>&lt;form&gt;
     ...
  &lt;spring:bind path="formData.foo"&gt;
      &lt;select name="&lt;c:out value="${status.expression}" /&gt;"&gt;
          &lt;c:forEach items="${foos}" var="foo"&gt;
              &lt;option value="&lt;c:out value="${foo.name}"/&gt;"&gt;
                  &lt;c:out value="${foo.name}"/&gt;
              &lt;/option&gt;
          &lt;/c:forEach&gt;
      &lt;/select&gt;
  &lt;/spring:bind&gt;
     ...
  &lt;/form&gt;
  </code></pre>
  
  <p>Some example solutions would be to use hidden fields to submit Foo's other properties and keep them in sync as the selection is changed, but I prefer not to use JavaScript in a situation like this where it will likely add confusion.  There are certainly other ways to accomplish this too.</p>
  
  <p>My question is does there exist any standard practice for accomplishing this?  Or should I just come up with my own way of doing so?  I'd rather not re-invent wheels if possible, and this is so seemingly common that just winging it may not be the best approach.</p>