Look at jboss seam.
Overview of the solution:
bind the menu to the object (not id)
select items of the objects
use an entity converter to convert to and from strings (using the PK
of your entity)
On Dec 14, 2007 8:42 AM, Rene Guenther <[EMAIL PROTECTED]> wrote:
>
> I got an manyToOne mapping from User to Cost Center.
> On my userForm.jsf I got sth like
>
> <t:selectOneMenu value="#{userForm.user.ccenter.id}" id="cc" required="true"
> styleClass="select" />
> <f:selectItems value="#{ccManager.objects}" />
> </t:selectOneMenu>
>
> userForm.user.getCcenter() is "under control" of hibernate. If I select a
> new cost center this results in a change of the value of
> userForm.user.getCcenter().getId(). Before saving the user I have to
> retrieve the new cost center object from the database. Until now everything
> works.
>
> Lets say I got for some reason another user object in my session. This user2
> is assigned to the same cost center, this results to user.getCcenter() ==
> user2.getCcenter(); not just equals. Now I might come into trouble if I
> change the id of the cost center of user by selecting a new one with
> selectOneMenu, because user2.getCcenter().getId() will be changed too of
> course.
>
> You know whether there is a recommended way how to use manyToOne mapping
> together with a selectMenu?
>
> Thanks
> René
>
> --
> View this message in context:
> http://www.nabble.com/Hibernate-ManyToOne-and-JSF-SelectMenu-tp14338207p14338207.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>