9 Replies Latest reply on Jan 3, 2007 7:55 PM by hstang

    Outject/Inject across a regular HTML link

      (This is similar to my previous post, but a different problem so it's a new post.)

      I outject an entity from a SLSB and an HTML page gets rendered (through a redirect) with a HTML link on it. The user clicks that link and the action method of that link is bound to a SFSB that would like to inject that same entity.

      Is this possible? Would the SFSB ever be able to access the outjected entity from the SLSB in the previous, unrelated request?

      I'm using an SMPC in both the SLSB and SFSB:

      @In(create=true)
      private EntityManager em;

        • 1. Re: Outject/Inject across a regular HTML link

          Your entity probably needs to be scoped to conversational or session scope in order for it to 'last' between requests.

          • 2. Re: Outject/Inject across a regular HTML link

            That's probably not it... Entity beans are by default scoped to the Conversation scope, and I haven't overridden that setting.

            • 3. Re: Outject/Inject across a regular HTML link

              Create a long running conversation. your entity will last longer instead of disappearing a temporary conversation (which only lasts for a request)

              • 4. Re: Outject/Inject across a regular HTML link

                Now I'm even more confused: The documentation says "Entity bean components do not support bijection or context demarcation. Nor does invocation of an entity bean trigger validation."

                Does this mean I can't use bijection with an entity bean and therefore can't pass it between session beans?

                • 5. Re: Outject/Inject across a regular HTML link
                  jblackmore

                  Hrrrm, I think that must pertain to the entity itself. It certainly doesn't mean you can't inject an entity into a session bean, because I do it all the time.

                  How about outjecting the entity from the SLSB with (scope=SESSION)? Do you really not want it session scoped? I think bsmithjj and hstang are right - your conversation is ending, taking your entity with it.

                  • 6. Re: Outject/Inject across a regular HTML link

                    It means that you cannot inject values INTO an entity. The entity itself can be in/out-jected by another component.

                    • 7. Re: Outject/Inject across a regular HTML link

                      John, thanks I'll give it a shot. Btw, could you describe under what circumstances a conversation would end, as you said? I've been guessing (e.g. "when a new link is encountered" and stuff like that) but I'd really like the actual guidelines as to what things cause it to end (apart from an explicit @End, because I don't have that in my situation).

                      • 8. Re: Outject/Inject across a regular HTML link

                        Yes, putting it in Session scope worked, thanks.

                        Could somebody please help me understand how the Seam-Managed Persistence Context (SMPC) eliminates LazyInitializationExceptions (LIEs)?

                        I do not understand how it does this, but am confident that it's pretty important information (as I got a LIE during this exercise).

                        • 9. Re: Outject/Inject across a regular HTML link

                          If you have a long running conversation, Seam provides a special EntityManager em along with it. It's special because it lasts as long as the conversation, and the instances that em fetches will become managed, and not detached, throughout the entire conversation. So you will avoid LIE.