This content has been marked as final.
Show 4 replies
-
1. Re: Add/Edit Page
pmuir Jul 19, 2006 5:18 AM (in response to mrwhite)Yes.
It's very hard to give help for such a non-specific problem, but some ideas
* Use facelets and templating to create a generic form which can be embedded
* Think about where you whether you are going to use conversations, and if so, where you want them to start/end and when you want to enable/disable their propogation
* Consider what the differences are between persisting a new object and updating an existing one -
2. Re: Add/Edit Page
mrwhite Jul 19, 2006 8:15 AM (in response to mrwhite)Lets take the blog example.
I have my BlogService thats hast the following code:@RequestParameter("blogEntryId") private String blogEntryId; @In(required=false) @Valid private BlogEntry newBlogEntry; @Factory("newBlogEntry") public void createBlogEntry() { if(blogEntryId != null) { newBlogEntry = get Blog by ID ... } else newBlogEntry = new BlogEntry(); } public String saveEntry() { em.persist(newBlogEntry); return "home"; }
The action is always: action="#{blogService.saveEntry}"
Is that the right way to solve this? -
3. Re: Add/Edit Page
gavin.king Jul 19, 2006 1:36 PM (in response to mrwhite)You would have to use merge() instead of persist().
-
4. Re: Add/Edit Page
bfo81 Jul 20, 2006 5:14 AM (in response to mrwhite)Whow... I always thought one should use persist() for new entities and merge() for existing edited entities. Now I know that all you need is merge(). Thanks Gavin ;).