-
1. Re: Displaying EJBs within JavaScript: what about the Entity
smokingapipe Aug 11, 2006 10:08 PM (in response to smokingapipe)Obviously, the title should be "JSP", not "JavaScript".
-
2. Re: Displaying EJBs within JavaScript: what about the Entity
smokingapipe Aug 13, 2006 3:40 AM (in response to smokingapipe)Any ideas on this? I've looked around the net and seen that I'm obviously not the only one who is encountering this issue. You grab your EJBs somehow while in a JSF backing bean, and then when JSP tries to display them, it's an error because they are detached and some members are not initialized.
Solution 1: Use a Filter that keeps an EntityManager hanging around for the duration of the request. Seems like an ugly way to do it, but I guess that would be "PHP-style", where it automatically frees DB connections when the request is finished.
Solution 2: Use Seam. Looks like a lot of people like that idea. I'm thinking about doing it, but I need to get this application in demo soon, and I'm not sure if I want to take on yet another layer of complexity here. On the plus side, Seam looks quite interesting. Is this the way to do it?
Solution 3: Anything else?
This is a problem that would be universal in any type of JSP + EJB application, so I'm surprised at how hard it is to find answers on this. Please let me know if you have ideas. -
3. Re: Displaying EJBs within JavaScript: what about the Entity
smokingapipe Aug 13, 2006 3:46 AM (in response to smokingapipe)By the way, it seems like ideally this is something that would be handled within the Servlet container itself. You should be able to register some kind of listener for the creation of a Request object and then another for when it is finished, which should be able to handle things like attaching and detaching an entity manager.
-
4. Re: Displaying EJBs within JavaScript: what about the Entity
raja05 Aug 13, 2006 5:43 AM (in response to smokingapipe)"SmokingAPipe" wrote:
Solution 1: Use a Filter that keeps an EntityManager hanging around for the duration of the request. Seems like an ugly way to do it, but I guess that would be "PHP-style", where it automatically frees DB connections when the request is finished.
This is how the OpenSessionInView works and I believe is the only way available if you dont want to get to Seam. Check this post
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=88460
for some differences in Seam managed persistence context Vs. EJB3's Extended Persistence context that will make applications not worry about LazyInitExceptions. -
5. Re: Displaying EJBs within JavaScript: what about the Entity
smokingapipe Aug 13, 2006 1:46 PM (in response to smokingapipe)Thanks Raja. This problem seems quite absurd, because there's not much use to EJBs if there isn't an easy and reliable way to render them in JSP. There really should be some part of the Request object that makes it possible to manage request-scoped resources.
I think I'll take the plunge and do this with Seam. It looks like it was really designed to do all this stuff. I'm not thrilled to have to learn yet another framework when I have a deadline to meet, but either I move forward (Seam) or backwards (PHP).