users@glassfish.java.net

Enity dependencies in JSF

From: <glassfish_at_javadesktop.org>
Date: Fri, 27 Mar 2009 08:11:26 PDT

Hi, I need a second opinion about a design issue. I have an entity, call it "Company". A Company have a relation with the entities "CompanyDetails" and "ContactDetails".

I also have a ManagedBean called CompanyMB in the request scope.

At page1.jsp a Company is created with all it's dependencies. At creation all entities get their ID:s which are generated.
At page2.jsp i must be able to update the same Company. This means that i need the PK of all entities, (Company.id, CompanyDetails,id, ContactDetails.id).

Should I save thes ID:s in inputHidden fields in page2.jsp as:
<h:inputHidden id="companyId" value="#{companyMB.id}" immediate="true"/>
<h:inputHidden id="companyDetailsId" value="#{companyMB.companyDetails.id}" immediate="true"/>
<h:inputHidden id="contactDetailsId" value="#{companyMB.contactDetails.id}" immediate="true"/>

OR, should I handle this in the service EJB by looking up the CompanyDetails,id and ContactDetails.id when saving (merging) the Company entity? If I do not have these ID:s the EntityManager will create new instances when I call the merge operation for the Company.
[Message sent by forum member 'nightzero' (nightzero)]

http://forums.java.net/jive/thread.jspa?messageID=339346