4 Replies Latest reply on Sep 30, 2005 11:33 AM by rdewell

    Problem setting context variables programmatically (in a Vie

    rdewell

      I have a custom ViewHandler implementation that needs to setup a conversation bean in the createView method. The problem is that I can't find a good way to do this that ALSO "activates" the conversation context... i.e. adds it to the conversation context. My bean is annotated:

      @Stateful
      @Scope(ScopeType.CONVERSATION)
      @Name("AppView")
      @Interceptor(SeamInterceptor.class)

      In my view handler, I acquire the bean in createView using JNDI:

      ... lookup(AppView.class.getName())

      This works fine. I now have an instance to my AppView bean, and I perform the needed "setup". Now, how do I make Seam aware of AppView...? I can't set it in the Contexts.getConversationContext() myself because that context is not yet "active". And, it isn't "automatically" available in the conversation context either.

      I've also tried acquiring the bean a different way than JNDI, using a pure JSF expression. But, I get a similar problem. This type in the form of an exception: Caused by: java.lang.IllegalStateException: No conversation context active.

      In short, I guess I need to know a way to programmatically populate and/or activate the conversation context for this specific circumstance.

      Ryan

        • 1. Re: Problem setting context variables programmatically (in a

           

          "rdewell" wrote:

          This works fine. I now have an instance to my AppView bean, and I perform the needed "setup". Now, how do I make Seam aware of AppView...? I can't set it in the Contexts.getConversationContext() myself because that context is not yet "active". And, it isn't "automatically" available in the conversation context either.


          With Seam, you have your EJB container and then you have the SeamDeployer. The SeamDeployer needs to be able to reference the target Stateful EJB too, are you deploying with the recommended JBoss version, or Tomcat?

          • 2. Re: Problem setting context variables programmatically (in a
            rdewell

            This is all using the JBoss version specifically compiled for Seam.

            Acquiring AppView.class via JNDI works just fine. I don't suspect there is any other way to acquire it in the ViewHandler, is there? But from there it is not getting automatically put in to the ConversationContext, nor do I seem to be able to programatically add it to that context (context not "active"). I even tried using InterceptorType.ALWAYS thinking that it might have to do with the phase JSF is in when calling createView, and so the SeamInterceptor was just not dealing with AppView... No luck.

            Ryan

            • 3. Re: Problem setting context variables programmatically (in a

              I would try grabbing the AppView by name from EL.

              Conversations are started and ended in the Invoke Action phase.

              • 4. Re: Problem setting context variables programmatically (in a
                rdewell

                Yeah, I tried grabbing it by EL, but receive the error:

                Caused by: java.lang.IllegalStateException: No conversation context active

                I'm getting the impression that this just isn't possible?

                Ryan