myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From René Günther <>
Subject EL and nested objects
Date Thu, 10 May 2007 06:06:46 GMT

assume I got a document bean and a costcenter bean (mapped to tables). The
document is assigned to a costcenter. The costcenter got two properties: id
(Long) and code (String). The user may edit the assignment by providing
another costcenter code for the document. In JSF this could look like that

<h:inputText value="#{documentForm.document.costcenter.code}" />

I run into 2 problems with this:
I am using Hibernate (dont know whether this applies to other persistence
frameworks also), if I retrieve a document from the DB which is not assigned
to a costcenter this will throw a "could not update model" error, since
document.getCostcenter() == null. This I found also mentioned in . I could assign new
Costcenter() to document but if user does not want to assign a costcenter I
would have to assign null before updating the document again with Hibernate
(Hibernate does not handle empty costcenter and null equally).

Other thing is, assume user works on two documents at once (eg within a
dataTable). Both documents are assigned to the same costcenter when
retrieving them from DB with Hibernate. If user changes the code of the
costcenter of one document this would apply to the other document also,
since document1.getCostcenter() == document2.getCostcenter().

How do you solve problems like this?

Right now I am considering the following solution:
1. Retrieving mapped objects from DB
2. Converting them into web layer objects like this:
3. User does stuff and finally pushes save button
4. Converting back by retrieving mapped objects:


View raw message