When you bind to the select lists you are actually only going to get the id (as a string) . Spring will not know how to convert this to a Sport object. To do this you will have write your own formatter. I will give you a overly simplified example but this is just for illustration. For your purposes it would make the most sense to make your formatter take a generic entity and do a find by id. This would look into persistence context for the entity with the given id.
Once again this an oversimplified example to illustrate the point..
home.jsp (only the form part)
Now the formatter this does the work converting the college id we receive into a college object. Remember this is over simplified in your case you would probably at the very least autowire in a service or repository to do a findById. If you wanted you could make it more generic to allow it to accept any entity type.
Now lastly we have to tell spring to use our new formatter in the controllers
Now when we get into the addPerson method of the controller after posting the form our Person object will have a fully populated College object on it, and there will not be any errors in the binding result which I am sure you probably had before.
Joined: Aug 18, 2012
Thank you very much! I solved that issue. I couldn't post before because I still have other problems with my application.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com