0 Replies Latest reply on Feb 23, 2006 5:54 PM by Dan Liu

    Conversation scoped back bean is created twice

    Dan Liu Apprentice

      I have a Seam component called BackA which is a back bean and it has a method like this:
      @Create
      public void init() {
      }

      It's referenced in PageA.xhtml. PageA.xhtml comes from a stateful bean method methodA() with @Begin @Factory annotated. There is a commandbutton in PageA.xhtml that calls the methodB() in the same stateful bean. Basically BackA is not refered in the stateful bean and only refered once in PageA.xhtml.

      When PageA.xhtml is being load, the following methods have been called:
      1.the methodA() of the stateful bean is called
      2. the init() of BackA is called.
      When click the button in PageA to trigger the methodB,the following methods have been called :
      1. the init() of BackA is called.
      2. the methodB() of the stateful bean is called

      As you can see init() is called twice. When init() is called on the second time, all class members are in null value, which means Seam is creating a new BackA twice.

      Changing BackA to session scoped and problem disappeared. This indicates that BackA doesn't behave like a conversation component. It behaves like a event scoped bean.

      Other people seem had same problem before and it's supposed to be fixed in beta 2. Here is the thred:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=73954

      I'm using beta2 but I still get the same problem. any idea?