Updating model relationship using h:selectOneListbox
posted 6 years ago
I am populating a table (h:dataTable) with a Hibernate managed collection. The table is populated fine using:
When I make a change to the "make" in this example and submit the form, the "make" field is correctly updated for the appropriate object in the collection.
My problem is in updating the "carCondition" using the h:selectOneListbox. I can understand why it wouldn't work; changing the "id" field in the embedded "carCondition" object, when I would really want the database relationship changed.
How should this best be done? Am I missing an easy way to do this or in my "actionListener" method should I just read the form parameters, find the correct value (the selected "carCondition" id), find the correct CarCondition object and update the "car" object myself? Is there an easier way?