Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes JSF and the fly likes Updating model relationship using h:selectOneListbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Updating model relationship using h:selectOneListbox" Watch "Updating model relationship using h:selectOneListbox" New topic

Updating model relationship using h:selectOneListbox

Lonnie Lewis

Joined: Mar 30, 2009
Posts: 8
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?
Karim Sherif

Joined: Nov 05, 2009
Posts: 1
Consider Paul's rocket mass heater.
subject: Updating model relationship using h:selectOneListbox
It's not a secret anymore!