3 Replies Latest reply on Jan 16, 2009 6:54 PM by newbie

    named bean doesn't get injectected into the Conversation scope

    newbie

      I'm new to Seam and am tasked with migrating a functioning enterprise app to Seam 2.1.1 GA.  I've removed the faces-config entries for the managed beans and annotated the beans with @Name(...), @In, @Out where appropriate. In the java code, if I call Seam.getComponentName(NavigationBean), the String, navigation is returned, as I would expect.  If I call Seam.componentForName(navigation) shouldn't I get back a managed instance of the NavigationBean? Right now NULL is returned. Likewise if I call Contexts.getConversationContext().get(navigation) NULL is returned. I thought the default context was CONVERSATION?


      Any input would be appreciated...

        • 1. Re: named bean doesn't get injectected into the Conversation scope
          swd847

          componentForName does something else altogether (it returns an instance of the Component class which contains metadata about the seam component). Component.getInstance(navigation) is what you are after.


          Contexts.getConversationContext().get(navigation) is not working for 1 of the following two reasons:


          1- the bean has not been created yet and so it not in the conversation context.
          2- the bean has been created but has a different scope so lives in a different conversation (does the bean have @Scope(ScopeType.CONVERSATION)?

          • 2. Re: named bean doesn't get injectected into the Conversation scope
            newbie
            Thanks!
            I've tried Component.getInstance("navigation") and it resolves to null, but you're correct, that's the method I wanted. Yep, I have the bean annotated with @Scope(ScopeType.CONVERSATION)

            No beans appear to be managed. the first xhtml in the application tries to render widgets with bean references such as "#{webRegistry.menuItems}",  "#{!navigation.passwordChangeRequired}", "#{search.searchTableName}" etc. All the beans were managed with jsf and were working just fine. Now with Seam they all resolve to null. Any ideas?
            • 3. Re: named bean doesn't get injectected into the Conversation scope
              newbie

              I find it odd that if I call Seam.getComponentName(NavigationBean), the String, navigation is returned, but that all beans resolve to null.