This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
Don't get me started about those stupid light bulbs.
subject: Updating model relationship using h:selectOneListbox
Similar Threads
Setting up a JSF project with data tables
Problem with submit()
datatable - row colors
Nested datatables
Array of Object in DataTable